Disable the "post info" text for custom post types

Community Forums Forums General Discussion Disable the "post info" text for custom post types

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  GermanKiwi 1 year, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #52793

    GermanKiwi
    Participant
    Post count: 15

    Hi, I’m using Genesis Framework along with the Simple Edits plugin, and I’ve got the “Post info” configured there so that each post says “Posted on 27 June 2013″ (or whatever the date is).

    I also have another Custom Post Type on my website which is created by another plugin – it creates its own set of posts within this Post Type, which appears in a different section in the WP Admin sidebar. And I have those posts listed at a different URL on my website than where the regular posts are listed.

    For those custom posts, I *don’t* want the “Posted on” entry appearing for each post. I only want that bit of text appearing for the regular posts, and not for any Custom Post Type.

    So my question is whether it’s somehow possible to have the Post Info data only generated for the regular posts and not for the custom posts? Maybe there’s something I can put in my theme’s functions.php or something like that?

    One option I’ve considered is just using CSS to hide the “Posted on” entry for the custom posts, by using display:none. This would work, but I’d prefer not to have the text generated at all, if that’s possible.

    Any ideas?

    #52797

    Stewart
    Participant
    Post count: 156

    Hi,

    A couple of ideas come to mind you could create custom templates for your CPT and remove the post_info:

    single-{post_type}.php and/or archive-{post_type}.php – More Info

    Or you could conditionally remove the post_info based on your CPT, example below:

    [php]
    function sc_remove_cpt_post_info( $query ) {
    if ( is_post_type_archive(‘CHANGE TO YOUR CPT’) ) {

    //* Remove the post info function
    remove_action( ‘genesis_before_post_content’, ‘genesis_post_info’ ); // Use this line if using pre Genesis 2.0

    remove_action( ‘genesis_entry_header’, ‘genesis_post_info’ ); // Use this line if using Genesis 2.0 with HTML5 activated
    }
    }

    add_action(‘pre_get_posts’, ‘sc_remove_cpt_post_info’);
    [/php]

    Just add the above code to your child themes functions.php
    Theres a couple of things above you will need to change the “CHANGE TO YOUR CPT” and also remove either of the post_info functions based on what version of genesis you are running.

    (edit)

    If you also want to remove is on the single CPT page also change this line:

    [php]
    if ( is_post_type_archive(‘CHANGE TO YOUR CPT’) ) {
    [/php]

    To

    [php]
    if ( is_post_type_archive(‘CHANGE TO YOUR CPT’) || ‘CHANGE TO YOUR CPT’ == get_post_type() ) {
    [/php]

    Hope this helps
    Stewart


    WordPress Developer – Need help upgrading to Genesis 2.0?My Blog
    Follow me on Twitter

    • This reply was modified 1 year, 4 months ago by  Stewart.
    • This reply was modified 1 year, 4 months ago by  Stewart.
    #52838

    GermanKiwi
    Participant
    Post count: 15

    That worked perfectly, thanks! I used the functions.php method as I haven’t gotten around to creating custom templates yet. :)

    Cheers!

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

You must be logged in to reply to this topic.