- This topic has 11 replies, 2 voices, and was last updated 3 years, 7 months ago by
Leo.
-
AuthorPosts
-
September 18, 2018 at 5:16 am #680039
Leon
On the homepage I want to show the newest post as “featured post”. That works well, but now the newest post in the search and category pages are also “featured posts”. As it doesn’t make any sense there, I’d like to exclude those pages. I can’t find any solution so far.
Thanks,
LeonGP Premium 1.7.2September 18, 2018 at 9:41 am #680362Leo
StaffCustomer SupportHi there,
You can use the option_generate_blog_settings filter.
The code should be this:
add_filter( 'option_generate_blog_settings', 'lh_disable_featured_column' ); function lh_disable_featured_column( $options ) { if ( ! is_home() ) { $options['featured_column'] = false; } return $options; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if this helps π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 20, 2018 at 3:19 am #681938Leon
Thanks a lot, Leo. It worked right away.
LeonSeptember 20, 2018 at 9:33 am #682328Leo
StaffCustomer SupportNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 20, 2018 at 2:46 pm #682513Leon
I see now it doesn’t totally work. On the non-homepages the lay out is the way it should be, but the length of the exerpt still has the length of the “featured post” form the home page.
Home is: http://l-seven.nl/wordpress/?page_id=12455
That is the way home should be.Non-home is e.g.: http://l-seven.nl/wordpress/?cat=4
As I wanted it doesn’t have the lay out of the home page featured post but unfortunately it still has the length. Can that be fixed in the snippet?Thanks,
LeonSeptember 20, 2018 at 4:38 pm #682548Leo
StaffCustomer SupportThe function above is just for columns.
How did you set the excerpt length specifically for the featured post?
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 21, 2018 at 12:24 am #682746Leon
I found this snippet (on this site, I’m sure):
add_filter( ‘excerpt_length’, ‘tu_featured_excerpt_length’, 50 );
function tu_featured_excerpt_length( $length ) {
$paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1;
global $wp_query;if ( 1 == $paged && 0 == $wp_query->current_post ) {
return 140; // First post
}return $length;
}and made the setting “140”
Leon
September 21, 2018 at 9:31 am #683159Leo
StaffCustomer SupportThat case we need to modify that code:
add_filter( 'excerpt_length', 'tu_featured_excerpt_length', 50 ); function tu_featured_excerpt_length( $length ) { $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; global $wp_query; if ( 1 == $paged && 0 == $wp_query->current_post && is_home() ) { return 140; // First post } return $length; }
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/September 27, 2018 at 6:01 am #687648Leon
Thank you, that worked.
But now the client wants to maintain the strong and <p> tags in the excerpt. I found a plugin that does that (Advanced Excerpt), but unfortunately it seems to overrule the snippets’s longer “excerpt length” on the homepage.
Is there a snippet that does the same trick as the plugin? Or can I make the snippet “win” from the the plugin?Thanks, Leon
September 28, 2018 at 11:04 am #688825Leo
StaffCustomer SupportHmm you could try using the more tag to keep the HTML:
https://docs.generatepress.com/article/using-the-more-tag/Or use the custom excerpt box.
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 3, 2018 at 3:42 am #692254Leon
The more tag works well. I only hope the author will remember to use it in the new “featured post”, and remember to remove it in the old “featured post”.
Thanks, LeonOctober 3, 2018 at 9:05 am #692631Leo
StaffCustomer SupportNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.