Skip to content

Instantly share code, notes, and snippets.

@QROkes
Created July 25, 2018 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QROkes/558ab764b750a36e3f5a3061eee67a28 to your computer and use it in GitHub Desktop.
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.
<?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');
<?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