Tag Info

New answers tagged

1

In my effort to solve this I discovered a great resource for wordpress hooks for the job and found the right hook wpseo_saved_postdata here. Feel free to modify the code if you think it could be better. For now, it works for me. function set_noidex_when_sticky($post_id){ if ( wp_is_post_revision( $post_id ) ) return; //perform other checks ...


0

Why don't you just check if the post is sticky and then add noindex? You can use the Conditional Tag is_sticky(). So, in your <head> tag in your header.php file, do the following check: if ( is_sticky() && is_single() ) { // it's a post and it's sticky, let's add noindex echo '<meta name="robots" content="noindex">'; }


0

To add to Ahmad's answer you could just remove all html comments with the same amount of code, since Yoast isn't the only plugin that does that. <?php function remove_html_comments_buffer_callback($buffer) { $buffer = preg_replace('/<!--[^\[\>\<](.|\s)*?-->/', '', $buffer); return $buffer; } function ...


0

In Yoast SEO there is no variable available for the content. The 2 variables that are available are %%excerpt%% and %%excerpt_only%%. The difference between these 2 is: %%excerpt%% - Replaced with the post/page excerpt (or auto-generated if it does not exist) %%excerpt_only%% - Replaced with the post/page excerpt (without auto-generation) For ...


2

Here is a safe and Yoast preferred method add_action('wp_head','add_custom_meta_description_box'); function retrieve_var1_replacement( $var1 ) { global $post; return strip_tags($post->post_content); } function register_my_plugin_extra_replacements() { wpseo_register_var_replacement( '%%mycustomdesc%%', 'retrieve_var1_replacement', ...



Top 50 recent answers are included