Community Forums › Forums › Archived Forums › Design Tips and Tricks › Is it possible to remove support for not displaying excerpts?
- This topic has 4 replies, 2 voices, and was last updated 7 years, 8 months ago by MCCCXXXI.
-
AuthorPosts
-
August 4, 2016 at 2:47 pm #190747MCCCXXXIMember
Hello all,
First of all, I am sorry if I did not post this thread in the right forum category. I am not sure if it would better go here or in General Discussions.
My question is quite simple: I am working on a theme (using Genesis, should that be even mentioned). I want that, for any page displaying a list of posts (like the home page, an archive page), the posts being displayed only have their excerpts shown (or the first 55 characters or any other number) and not their full content.
I perfectly know it's easy to do so by checking the right box in WordPress's administration panel, but I do not want that to be a choice. I'd like to have it as the default and only option (well, then it wouldn't be an option).
It's exactly like the layout option. To force your Genesis theme to be full width, you just have to call a few functions (genesis_unregister_layout( 'content-sidebar' ), etc.). I was wondering if it is the same for the displaying of posts in lists. Such feature would be greatly appreciated.Thanks a lot!
August 4, 2016 at 6:10 pm #190754ChristophMemberHi,
this should do the trick:
add_filter( 'genesis_archive_display_options', 'ch_remove_excerpts_from_content_archive_display_option' ); /** * Removes the Entry excerpts display option from Genesis Theme Settings Content Archives * box. * * @param array $archive_display Existing display types. * @return array Amended display types. */ function ch_remove_excerpts_from_content_archive_display_option( array $archive_display ) { if ( isset( $archive_display['excerpts'] ) ) { unset( $archive_display['excerpts'] ); } return $archive_display; }
August 5, 2016 at 3:56 am #190767MCCCXXXIMemberThank you, I will try this out! This is to remove the option of displaying the full content of each of the posts in pages listing several posts right? (and not to remove the option of displaying excerpt) Well, even if it's the case, that's not a problem, it will be easy to reverse the behaviour of the code!
August 5, 2016 at 7:58 am #190773ChristophMemberSorry, I must have misread.
To remove the full content option, change $archive_display['excerpts'] to $archive_display['full']'.
August 9, 2016 at 4:23 am #190955MCCCXXXIMemberThank you, it perfectly works!
This bit of code has removed the post full content display option from the dashboard. I managed to remove it from the customizer with this code placed in functions.php of the child theme:/** * Remove the choice from the customizer. */ add_action( 'customize_register', 'remove_full_content_customizer', 16 ); function remove_full_content( $wp_customize ) { $wp_customize->remove_control( 'genesis_content_archive' ); }
Lastly, to make sure Genesis and the child theme behave as if the user chose excerpt display, this code has to be added in functions.php of the child theme:
/** * Force Genesis to display exceprt instead of full content in lists of posts. */ add_filter( 'genesis_pre_get_option_content_archive', 'force_excerpt_display' ); function force_excerpt_display() { return 'excerpts'; }
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.