Filter post_meta in custom post types

Community Forums Forums Design Tips and Tricks Filter post_meta in custom post types

This topic is: not resolved

This topic contains 1 reply, has 2 voices, and was last updated by  Aaron Eaton 1 year, 1 month ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #65811

    capiedge
    Participant
    Post count: 5

    I have various Custom Post types declared, and I want to display as post meta information:
    – in normal post: “filed under: category1, category2…”
    – in the custom post type: “filed under: term1, term2…”

    The code copied below, works perfect for normal posts, but in custom posts it repeats two times the “Filed under:”, the first one is empty, and the second one with the terms.

    add_filter( 'genesis_post_meta', 'post_meta_filter' );
    function post_meta_filter($post_meta) {
    	if ( !is_page() ) {
    		$post_meta = '	[post_categories before="Filed Under: "]
    						[post_tags before="Tagged: "]
    						[post_terms taxonomy="agenda" before="Filed under: "]
    		';
    	return $post_meta;
    		}
    }

    How could I get only the second “Filed under” for custom post types?
    Any conditional order to specify that if categories is empty, don’t show its field?
    Thank you!

    #73674

    Aaron Eaton
    Participant
    Post count: 28

    You’ll probably need a couple of conditionals to target the elements you need to properly show “Filed Under:”.

    is_singular()

    is_post_type_archive()

    For conditionally showing the categories text:

    has_category()



    J. Aaron Eaton – WordPress Consultant
    Website

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.