• Resolved finanzbeben

    (@finanzbeben)


    Hi there, we are trying to return the Yoast SEO metadescription for GenerateBlocks. However, we are not seeing any code to get the Yoast meta description online aside from that code beneath which isn’t working.

    add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){
    	if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'get-yoast-desc' ) !== false ) {
    		$yoast_meta = YoastSEO()->meta->for_current_page()->description;
    var_dump($yoast_meta);
    		if($yoast_meta){
    			return $yoast_meta;
    		}
    	}
    	return $content;
    }, 10, 3);

    Could you check if there is a possibility to retrieve the Yoast meta description for the Search page in PHP?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Maybellyne

    (@maybellyne)

    Hello @finanzbeben,

    Thanks for reaching out but what you’re trying to achieve is unclear. Can you expatiate on what you mean by returning the Yoast SEO metadescription for GenerateBlocks. Did you have the meta description filled in but deleted at some point??

    Thread Starter finanzbeben

    (@finanzbeben)

    Hello Maybellyne,

    Sorry for causing some confusion. We’ve encountered an issue with retrieving the Yoast meta description for our search page using PHP, and would greatly appreciate your guidance.

    Objective: We aim to dynamically display the Yoast meta description on our search page (for search results). This is intended to enhance the SEO and user experience of our site.

    What We Have Done:

    1. Page Setup: On our Search Page Block Element – Page Hero, we have added a GB Headline Block with a class of ‘get-yoast-desc’. Reference for adding custom classes: WordPress Editor – Adding Additional CSS Classes to Blocks.
    2. Dynamic Data Activation: We have enabled dynamic data on this block to grab the title.
    3. PHP Snippet Added: We incorporated the above mentioned PHP snippet using the Code Snippets (PHP) plugin:

    Issue Encountered: The block is currently only returning the title and not the Yoast meta description as intended. We attempted debugging by updating the code to include var_dump($yoast_meta);, but it seems the Yoast meta description is not being retrieved.

    Request for Assistance: Could you provide guidance or an alternative code snippet that would enable us to retrieve the Yoast meta description for the Search page in PHP? We believe there might be a specific approach or function required for this purpose that we are currently unaware of.

    Your expertise and assistance in this matter would be immensely valuable to us. We are looking forward to resolving this issue and improving our site’s functionality with your esteemed guidance.

    Thank you for your time and support.

    Kind regards

    Plugin Support Maybellyne

    (@maybellyne)

    Thanks for providing more explanation but we aren’t able to provide this level of support in the forums. These forums are dedicated to offering support for the plugin, but this unfortunately doesn’t include development support so we aren’t able to offer support on custom code (needed to change core features of our plugin). Maybe someone watching these forums can assist you further, but if your topic is inactive, we’ll mark it as resolved to keep the overview.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Get PHP Yoast Meta description’ is closed to new replies.