• Resolved online0227

    (@online0227)


    In admin setting->SEO->Search Appearance-> Content Type, I put default meta desc as “%%excerpt%%” for pages and posts. Now it pulls out from some text in all pages and put it into meta desc, but the problem is that for every pages, it pulls out texts from what I don’t want it to pull out.

    I gave those sections, in which I don’t want yoast to pull out for deciding final meta description to show, specific id (like <section id=”blahblah”>) using Elementor, and I want to change Yoast’s behavior how it pulls out text in every pages so that it ignores and skip tags with specific id for pulling out. I am pretty sure I need to do some regex thing to ignore tags with specific id I set, but unsure which part of yoast or wordpress or theme sources code I need to alter in order to change default behavior of %%excerpt%% set via Yoast’s setting.

    Which part of Yoast source code should I change in order to achieve this, or should I make additional snippet of php code that captures texts before yoast decides final meta description?

    • This topic was modified 2 years, 12 months ago by online0227.
    • This topic was modified 2 years, 12 months ago by online0227.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Michael Ti?a

    (@mikes41720)

    Hi @online0227

    If you are using the %%excerpt%% variable, it should take the first 55 words from the content. There’s a specific excerpt field for posts, but for pages, it might just pull from the content itself and if you’re using a page builder, it’ll pull from the code.

    In this case, we recommend either using a different snippet variable that would better suit the meta description template – https://yoast.com/help/list-available-snippet-variables-yoast-seo/

    Thread Starter online0227

    (@online0227)

    Hello, @mikes41720
    This seems be not the answer I wanted to know.

    I want Yoast to exclude html tag that has specific id I set (e.g. <div id=”yoast-exclude”>…</div>) from creating final meta description.

    I checked up the page https://yoast.com/help/list-available-snippet-variables-yoast-seo/ but there seems to be no snippet variable doing such thing. Therefore I need to do regex thing to capture such html tag with specific id in yoast/wordpress backend and remove such tag with specific id before creating final meta desc to show, but I just don’t know which part of source code I should modify.

    Thank you very much.

    Plugin Support Michael Ti?a

    (@mikes41720)

    Hi,

    It looks like you’re looking for the excerpt variable to ignore parts of code from the page content and just pull from the actual worded content. Are we understanding it correctly?

    We’re not sure how to manipulate this particular variable to suit your needs, but you can review all of our available developer documentation here – https://developer.yoast.com/

    You may want to try and use custom fields to generate some snippet variables so that it’ll fit your needs for the meta description output.

    Plugin Support Maybellyne

    (@maybellyne)

    Hi,

    This thread has been marked as resolved due to a lack of activity.

    You’re always welcome to re-open this topic. Please read this post before opening a new request.

    Thanks for understanding!

    Hi,
    I think this snippet can work to get an excerpt limited to 145 characters and create a yoast seo custom template variable.
    It will work in: Yoast SEO -> Search Appearance -> Content Types -> “use at your own convenience”.

    I hope it helps, and maybe is useful for this -> How to limit excerpt length?

    /*
    *
    * Yoast SEO custom variable: excerpt
    */
    // define the custom replacement callback
    function get_myexcerpt() {
    	// get the excerpt and limit to 145 characters
    	$excerpt = get_the_excerpt();
    	return substr($excerpt, 0, 145);
    }
    
    // define the action for register yoast_variable replacments
    function pjlm_register_custom_yoast_variables() {
        wpseo_register_var_replacement( '%%myexcerpt%%', 'get_myexcerpt', 'advanced', 'get the excerpt' );
    }
    
    // Add action
    add_action('wpseo_register_extra_replacements', 'pjlm_register_custom_yoast_variables');
    
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to customize default %%excerpt%% behavior by Yoast?’ is closed to new replies.