-
Stratos_K
Hello,
I have created a Query Loop in a specific page so it can show my last 10 posts I have made from a specific category of posts.
In each post of this Query I have added the featured image, the title, the category of the post and information about the author. Everything looks great so far. One thing that I cannot add is the post’s meta description.
What I have done is I added a Headline and enabled the Dynamic Data option. For Data Source I chose current post and Content Source Post Meta. But in the Post Meta list there is nothing to choose. It shows empty.
What am I doing wrong?
-
Fernando
Hi Stratos,
What “description” meta is this? Is it a custom meta you added? If so, try to add its slug in the field name manually.
-
Stratos_K
In the end of the block editor there are the AIOSEO settings with fields for Meta Title and Meta Description.
This Meta Description is the one I want to add.
-
Fernando
That seems to be from a plugin. Can you check? If not, can you share a screenshot?
-
Stratos_K
It’s from the All in One SEO plugin I believe. Is it possible to get the Meta Description from it to display in the Query Loop?
-
David
Hi there,
display All In One SEO AISEO Meta Description using dynamic data.
for reference i found this topic where the user provides some code to get the AIOSEO meta description:
We should be able to repurpose that.
1. Add this PHP Snippet to your site:
add_filter( 'render_block', function( $block_content, $block ) { if ( !is_admin() && function_exists('aioseo') && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'seo-description' ) !== false ) { $aioseo_description = aioseo()->meta->metaData->getMetaData($post)->description; if(!empty($aioseo_description)) { $post_id = get_the_ID(); $get_post = get_post($post_id); $meta_description = aioseo()->meta->description->getPostDescription($get_post); return $meta_description; } } return $block_content; }, 10, 2 );
2. Add a Headline block with some static text to your query loop and in its Advanced > Additional CSS Class(es) add:
seo-description
-
Stratos_K
Success! It works great! Thank you very much for the help!
-
David
Glad to hear that!
- You must be logged in to reply to this topic.