Need Help Displaying Manual Excerpts for Custom Post Type

Community Forums Forums Design Tips and Tricks Need Help Displaying Manual Excerpts for Custom Post Type

This topic is: resolved

This topic contains 6 replies, has 3 voices, and was last updated by  mohsin 1 year, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #7261

    mohsin
    Participant
    Post count: 8

    Hi,

    We are using Backcountry theme.

    I am stuck with one issue, i.e. in the archive page of the Custom-Post, auto exerpts are being shown, and not the hand-written excerpts which we have written for those CPT posts.

    Can you please guide, what could be the issue?

    Thanks,

    Mohsin

    • This topic was modified 1 year, 7 months ago by  mohsin.
    • This topic was modified 1 year, 7 months ago by  mohsin.
    #7295

    ryandonsullivan
    Participant
    Post count: 11

    Is this a custom post type that you added manually?

    You may just need to add the ‘excerpts’ to the ‘supports’ section of your CPT array.

    For example from the WordPress codex:


    add_action( 'init', 'create_post_type' );
    function create_post_type() {
    register_post_type( 'acme_product',
    array(
    'labels' => array(
    'name' => __( 'Products' ),
    'singular_name' => __( 'Product' )
    ),
    'public' => true,
    'has_archive' => true,
    ''supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo' ),
    )
    );
    }

    If your code doesn’t have the ‘excerpt’ explicitly defined then Genesis will fall back to the default auto-generated ones.

    If you’re adding your custom post type with a plugin or some other way, then pretty much everything above is useless ;)

    #7313

    mohsin
    Participant
    Post count: 8

    Hi ,

    Thank you for your reply.  Yes i am adding it manually from the functions.php file.

    I do have added that support in CPT function, and i see box in the admin panel, where we have added the custom hand crafted excerpts, our challenge is to display them at the front-end in the theme.. In the front-end , Genesis is showing auto excerpts and not checking/considering the manual excerpts before going to display the auto-excerpts.. what could be the solution to this please?

    Thank you,

    Mohsin

    #7710

    wpsmith
    Moderator
    Post count: 178

    You may want to check out Genesis CPT Archives plugin that may help you a bit.

    Please let me know if I can help any further.


    Travis Smith | Recommended StudioPress Developer & Contributor
    WP Smith | @wp_smith | GitHub

    Due to the forums, please paste code using Pastebin, JS Fiddle (for JavaScript) or GitHub.
    How to use Firebug for Designers by SixRevisions

    #7745

    mohsin
    Participant
    Post count: 8

    Hi,

    Thank you for your response. I am not sure if plugin will help in this situation, as we have already have all CPT code in place and templates ready. Also we have other CPTs with custom stuff on their archives pages so i am little scared to use plugin at this stage as it can conflict with other stuff.

    As most of the CPT archives have auto excerpts.. so thats great… i have only issue with this one particular CPT, which have manual excerpts inside it..but not outputting it on archive pages and still showing auto-excerpts which as per wp rules should only be considered if no manual excerpts found…

    I have tried to have empty arhive tempalte file for this CPT by having only GENSIS(); inside it.. Do not know where i have messed it up or any Genesis function which may need to be filtered/changed…

    Thanks for all the support.

     

    #7747

    wpsmith
    Moderator
    Post count: 178

    You can try something like this on your template that you tried (it could also go into functions.php).


    remove_action( 'genesis_post_content', 'genesis_do_post_content' );
    add_action( 'genesis_post_content', 'wps_cpt_do_post_content' );
    /**
    * Custom post content for cpt archive page
    */
    function wps_cpt_do_post_content() {
    if ( is_post_type_archive( 'wps_post_type_name' ) ) // change me to your registered cpt name
    the_excerpt();
    else
    genesis_do_post_content();
    }


    Travis Smith | Recommended StudioPress Developer & Contributor
    WP Smith | @wp_smith | GitHub

    Due to the forums, please paste code using Pastebin, JS Fiddle (for JavaScript) or GitHub.
    How to use Firebug for Designers by SixRevisions

    #7749

    mohsin
    Participant
    Post count: 8

    Hi Travis,

    Wow this worked. Thank you so much for your help. :)

    Thank you @WP_Smith for your time and help.

    Regards,

    Mohsin

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

You must be logged in to reply to this topic.