Excerpt Not Showing On Custom Theme Functions

#538849
  • Resolved Raw Videos
    Rank Math free

    Hello there,
    My client uses generatepress theme and he added some extra functions in single-content.php where it has some default short description text that is same for all posts but replaces specific text according to the tags of specfic post. So he doesnt have a habit of editing excerpt within the post editor and he wanted to auto display exceprt from the initial sentence of the post but in his case it is not is showing anything even after Single Post Description is enabled with %excerpt% / %excerpt_only%
    SInce its a podcast website he doesnt have any text content other than default decription within template itself. On frontend of website the text in post is visible with all tags in place but excerpt is not displayed in metadata.

    But If he writes any content with in post editor that text is displayed as excerpt as usual.

    is there any function to get rankamth generate excerpt based on frontend detection of the post as rankmath plugin is not able to gather data from theme template.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,

    Thanks for contacting us and sorry for the inconvenience caused.

    You can modify and use the following filter to add a description in the front end based on your setup: https://rankmath.com/kb/filters-hooks-api-developer/#change-meta-description

    Here is how to add a filter to your site: https://rankmath.com/kb/wordpress-hooks-actions-filters/

    Hope that helps. Let us know if you need any other assistance.

    May i know where exactly should i use this. I’ve already added that to functions.php and nothing happened.

    /**
     * Allow changing the meta description sentence from within the theme.
     *
     * @param string $description The description sentence.
     */
    add_filter( 'rank_math/frontend/description', function( $description ) {
    	return $description;
    });

    Hello,

    You can use the following filter or customize it as per your need:
    https://pastebin.com/ZpNmQRdj

    Hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    Thank you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)

The ticket ‘Excerpt Not Showing On Custom Theme Functions’ is closed to new replies.