Community Forums › Forums › Archived Forums › Design Tips and Tricks › Need Help Displaying Manual Excerpts for Custom Post Type
- This topic has 6 replies, 3 voices, and was last updated 12 years, 4 months ago by
mohsin.
-
AuthorPosts
-
December 24, 2012 at 10:38 am #7261
mohsin
MemberHi,
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
December 24, 2012 at 12:42 pm #7295ryandonsullivan
MemberIs 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 ๐
December 24, 2012 at 1:57 pm #7313mohsin
MemberHi ,
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
December 27, 2012 at 12:25 pm #7710wpsmith
MemberYou 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.
December 27, 2012 at 3:34 pm #7745mohsin
MemberHi,
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.
December 27, 2012 at 3:47 pm #7747wpsmith
MemberYou 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();
}
December 27, 2012 at 3:58 pm #7749mohsin
MemberHi Travis,
Wow this worked. Thank you so much for your help. ๐
Thank you @WP_Smith for your time and help.
Regards,
Mohsin
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.