Community Forums › Forums › Archived Forums › Design Tips and Tricks › Using custom excerpts
- This topic has 3 replies, 3 voices, and was last updated 10 years, 5 months ago by Genesis Developer.
-
AuthorPosts
-
August 4, 2014 at 6:31 pm #117067creative5designsMember
I have a site that I'm using the standard Genesis loop on, with the content limit showing, which is fine, but sometimes I'd rather show a manual excerpt instead of the content limit. Is there a way to have Genesis show the manual excerpt if it exists, otherwise show the content limit? (I'm sure this is probably an easy fix, I just can't seem to find it/make it work!)
Thanks in advance.
August 4, 2014 at 7:02 pm #117080ᴅᴀᴠɪᴅMemberIt's in the theme settings.
So Genesis > Theme Settings > Content Archives, select Display post excerpts.
Sorry if i misunderstood the question, but I think that is what you mean
I love helping creative entrepreneurs build epic things with WP & Genesis.
August 4, 2014 at 7:06 pm #117083creative5designsMemberThanks for responding David - I think I may not have worded my question very well.
I have the setting set to show the content limit, which is what I want most of the time. However, on a few posts, I would like to craft manual excerpts instead. So by default, it will show the content limit, but if a manual excerpt exists on a post it would show that.
I'm thinking it would be a php if/else statement in the functions to set this, I'm just not good enough with coding yet to know exactly how to craft the function.
August 4, 2014 at 11:06 pm #117120Genesis DeveloperMemberYes. There need a bit of PHP code and a custom meta variable. You'll assign the "manual_excerpt" meta key for manual excerpt post only. You can achieve it this way:
Step 1. Meta key = manual_excerpt
Step 2. Meta value = yes
Step 3. Rewrite the genesis_do_post_content function. Write the code in your functions.php file ( I did not test the code. So before you'll keep a backup of your functions.php file)
//removing the default genesis_do_post_content function remove_action( 'genesis_entry_content', 'genesis_do_post_content' ); //re-creating the new one "genesis_do_post_content_new" add_action( 'genesis_entry_content', 'genesis_do_post_content_new' ); function genesis_do_post_content_new(){ global $post; if ( is_singular() ) { the_content(); if ( is_single() && 'open' === get_option( 'default_ping_status' ) && post_type_supports( $post->post_type, 'trackbacks' ) ) { echo '<!--'; trackback_rdf(); echo '-->' . "\n"; } if ( is_page() && apply_filters( 'genesis_edit_post_link', true ) ) edit_post_link( __( '(Edit)', 'genesis' ), '', '' ); } elseif ( "yes" == get_post_meta($post->ID, 'manual_excerpt', true) || 'excerpts' === genesis_get_option( 'content_archive' ) ) { the_excerpt(); } else { if ( genesis_get_option( 'content_archive_limit' ) ) the_content_limit( (int) genesis_get_option( 'content_archive_limit' ), __( '[Read more...]', 'genesis' ) ); else the_content( __( '[Read more...]', 'genesis' ) ); } }
Good Luck!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.