Created
July 25, 2018 18:16
-
-
Save QROkes/558ab764b750a36e3f5a3061eee67a28 to your computer and use it in GitHub Desktop.
Add the META robots noindex for better SEO and avoid duplicate content in Question2Answer forum.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: SEO Custom Meta-Robots | |
Plugin URI: https://qrokes.com/ | |
Plugin Description: SEO Custom Meta Robots | |
Plugin Version: 1.0 | |
Plugin Date: | |
Plugin Author: QROkes | |
Plugin Author URI: https://qrokes.com/ | |
Plugin License: GPLv3 | |
Plugin Minimum Question2Answer Version: 1.8.0 | |
Plugin Update Check URI: | |
*/ | |
if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser | |
header('Location: ../../'); | |
exit; | |
} | |
qa_register_plugin_layer('qa-seo-custom.php', 'SEO Custom Meta-Robots'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Add Meta-Robots NOINDEX to all pages except for homepage and question pages. | |
*/ | |
class qa_html_theme_layer extends qa_html_theme_base | |
{ | |
public function head_metas() | |
{ | |
qa_html_theme_base::head_metas(); | |
if ( $this->template=='question' || $this->template=='qa' ) | |
$this->output('<meta name="robots" content="index,follow"/>'); | |
else | |
$this->output('<meta name="robots" content="noindex,follow"/>'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment