Created
February 4, 2013 15:31
-
-
Save gmajoulet/4707441 to your computer and use it in GitHub Desktop.
Wordpress plugin to use tags and category with custom post types
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: Tags search | |
Description: Permet de rechercher par tag dans tous les post types | |
Version: 1.0 | |
Author: Gabriel Majoulet | |
Author URI: http://www.gabriel-majoulet.fr | |
*/ | |
if(!class_exists('Tag_Rewrite')) { | |
class Tag_Rewrite | |
{ | |
function __construct() | |
{ | |
add_action( 'pre_get_posts', array(&$this, 'parseQuery') ); | |
} | |
function parseQuery($query) | |
{ | |
if (is_tag() || is_category()) { | |
$post_type = array('post', 'news'); | |
$query->set('post_type', $post_type); | |
} | |
return $query; | |
} | |
} | |
} | |
if(class_exists('Tag_Rewrite')) { | |
$tag_rewrite = new Tag_Rewrite(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment