Viewing 4 replies - 1 through 4 (of 4 total)
  • AddWeb Solution

    (@addweb-solution-pvt-ltd)

    @francoisduroy what do you mean by manual excerpt? Can you explain more so we can help you.

    Thread Starter Alberto Balsalm

    (@francoisduroy)

    Thanks for the reply..

    Sure..

    By “manual excerpt” I mean the excerpt field that a user would manually fill in the article edition panel.

    I intend to write a text in that field for all my articles.

    We know that the content of the this field has a priority over the excerpt WP generates from the first lines of the article. So “manual excerpt” of my articles will display for all my posts on all my pages.

    But, what I would like is to display the content of the “manually filled excerpt” on my homepage only, and use the normal excerpt play its role on other pages (the automatically generated one I mean).

    Thank you

    Thread Starter Alberto Balsalm

    (@francoisduroy)

    I found this article from someone filtering the_content to replace it with the excerpt : https://justintadlock.com/archives/2008/08/24/replacing-wordpress-content-with-an-excerpt-without-editing-theme-files#comment-2300679

    That function takes the manually filled excerpt into account. I tried to modify it but I can’t manage to adapt it for my needs.

    Thanks

    Thread Starter Alberto Balsalm

    (@francoisduroy)

    Hey,

    I found a way to do it with the help of someone who replied on my question on a Facebook group.

    If someone ever needs such a function this will help.

    function override_manual_excerpt( $content ) {
    if ( has_excerpt() && is_category() ) {
    $post_id = get_the_ID();
    $content_post = get_post($post_id);
    $content = wp_trim_excerpt(); 
    }
    return $content;
    }
    add_filter( 'get_the_excerpt', 'override_manual_excerpt' );
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Manual excerpt only on front_page’ is closed to new replies.