how to filter custom press custom post types?

When I look at the full list of my custom posts, there doesn't seem to be any way for me to filter those, like I would normally be able to filter by category with regular posts. Is there some setting I can enable to get this functionality? Kind of critical for ordering our content.

  • Jude
    • DEV MAN

    Hi there @peter_harris

    How are you filtering the posts ? If you want some sort of a front end interface then this seems to be a good way forward.

    Alternately if you are using WP_Query and prefer writing the filter than this is a good starting point

    $args = array(
    	'date_published' => '-1 year',
    	'book_type' => 'design',
    	'post_type' => 'books',
    	'orderby' => ' . $startDate . ',
    	'order' => 'ASC',
    	'posts_per_page' => 2000
    $selectedbooks = new WP_Query( $args );

    The post type here is Books. Date Published and Book Type are taxonomies.

    Feel free to get in touch for further assistance with this


  • Jude
    • DEV MAN

    It sure is familiar to me :smiley:

    I have written a custom function to do this for you.

    function custom_add_taxonomy_filters() {
    	global $typenow;
    	// Use the taxonomy name or slug
    	$taxonomies = array('date' , 'type' , 'venue', 'artist' );
    	// must set this to the post type you want the filter(s) displayed on
    	if( $typenow == 'modules' ){
    		foreach ($taxonomies as $tax_slug) {
    			$tax_obj = get_taxonomy($tax_slug);
    			$tax_name = $tax_obj->labels->name;
    			$terms = get_terms($tax_slug);
    			if(count($terms) > 0) {
    				echo "<select name='$tax_slug' id='$tax_slug' class='postform'>";
    				echo "<option value=''>Show All $tax_name</option>";
    				foreach ($terms as $term) {
    					echo '<option value='. $term->slug, $_GET[$tax_slug] == $term->slug ? ' selected="selected"' : '','>' . $term->name .' (' . $term->count .')</option>';
    				echo "</select>";
    add_action( 'restrict_manage_posts', 'custom_add_taxonomy_filters' );

    Just copy/paste the code into the functions.php file of your child theme or a site specific plugin if you use one.

    Let me know if it helps


  • Trevor
    • Flash Drive

    Hi Jude or other,
    Sorry to resurrect old issues!!
    I see you recommended for filtering of CustomPress Taxonomies. I'm struggling with this on my site as it seems to only work with one taxonomy and not the others. Is there something I should be doing in CustomPress with the Taxonomy setup as the plugin recognizes all the taxonomies, it just can't find the custom post that the taxonomies are related too! See site here

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.