How-to: This block can only be used once

WordPress doesn’t put restrictions on third-party blocks. The only way to ensure a block can be added only once per post (or Page, or CPT) is when registering it – meaning the restriction was added by Yoast. You could look into modifying the block yourself but there is usually a good reason when an author … Read more

Embed sitemap in a page

You can fetch all the different post_types you have by using get_post_types(). Then you can loop through all posts of each post_types and echo all these posts (title + link). That way you have the freedom of formatting your sitemap the way you want.

Yoast Metadata API to adjust/override the meta description

I think you’re on the right track here. You can use the wpseo_metadesc filter to alter the meta description any way you want. Check out below code, maybe it’ll help you with your function. add_filter( ‘wpseo_metadesc’, ‘my_custom_meta_description’ ); function my_custom_meta_description($description) { if ( !$description || empty($description) ) { global $post; $content = get_the_content($post->ID); if ( … Read more

Display Yoast meta-description `wpseo_desc` within loop of categories and fail silently if no data is set [closed]

You can just check if $meta and $meta_desc exist. If not, don’t echo anything. $popular_topics = get_field(‘popular_topics’); if ( $popular_topics ) : foreach ( $popular_topics as $topic ) : $id = $topic->term_id; $meta = get_option(‘wpseo_taxonomy_meta’); if ( $id && ( $meta && !empty($meta) ) ) : $meta_desc = $meta[‘category’][$id][‘wpseo_desc’]; if ( $meta_desc ) : ?> … Read more

How to use the Yoast SEO wpseo_canonical filter to set a canonical URL for /, /au/ & /uk/ sites in a MU environment

How would I use wpseo_canonical filter to set a canonical URL for the posts in www.example.com/uk/? E.g. the blog post www.example.com/uk/blog/post-1/ should have a canonical URL of www.example.com/blog/post-1/ I believe. I don’t know if that should be the canonical URL, but if you are asking how can that be done, then this would do it, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)