Hot answers tagged

17

It didn't say in the API docs on the Yoast SEO plugin site what the ID was and I don't have a copy of Yoast at installed at disposal, but according to yoas-plugin-dir/admin/class-metabox.php line 144, the meta_box registered is; add_meta_box( 'wpseo_meta', ...etc ); ... Which is hooked onto add_meta_boxes hook on line 32 of the same file, add_action( '...


11

On remove_meta_box is a note: Because you can't remove a meta box until it's been added, it's important to make sure your call to remove_meta_box() happens in the right sequence. WordPress SEO adds meta boxes on add_meta_boxes action with default priority - 10, which run after admin_init, so that won't remove them. Instead you need to hook into ...


11

The WPSEO plugin by Yoast has a filter for the title: 'wpseo_title'. You'll need to add something like this: add_filter('wpseo_title', 'filter_product_wpseo_title'); function filter_product_wpseo_title($title) { if( is_singular( 'product') ) { $title = //your code } return $title; } More info at the WordPress SEO API Docs page.


10

For reference the file that handles the tracking and usage statistics for Yoast SEO is located at, path/to/wp-content/plugins/wordpress-seo/admin/class-tracking.php I have linked to the GitHub repository file in question for further inspection upon which you can see somewhat, relatively, harmless collection of data. However what you determine as "...


9

Here's the general principle of what you need to do: Hook into the wpseo_breadcrumb_links or wp_seo_get_bc_ancestors API filters. Add your Blog into the WordPress SEO Breadcrumb $links array, using array_splice. Place this in your theme's functions.php: /** * Conditionally Override Yoast SEO Breadcrumb Trail * http://plugins.svn.wordpress.org/...


8

Get Archive SEO titles If you defined a Custom Post Type archive title you can get that by: $titles = get_option( 'wpseo_titles' ); $title = $titles['title-ptarchive-POST_TYPE']; echo apply_filters( 'the_title', $title ); Remember to replace POST_TYPE by your own Custom Post Type. To display all the wpseo_title variables, you can use: printf( '<...


6

A simple way to achieve this (but without the Class approach) is by filtering the output of wp_head action hook using the output buffering. In your theme's header.php, wrap the wp_head() call with ob_start($cb) and ob_end_flush(); functions like: ob_start('ad_filter_wp_head_output'); wp_head(); ob_end_flush(); Now in theme functions.php file, declare ...


5

Unless the plugin has made significant database changes, you could follow these steps to downgrade it: Download and extract the old version from the plugin repository Disable the plugin Log on to your server with FTP or SSH Upload the old plugin directory to wp-content/plugins/. (You would want to overwrite the newer version.) Reactivate the plugin Here'...


5

You can remove it using the remove_meta_box function. if ( ! current_user_can( 'edit_pages' ) ) { add_action( 'add_meta_boxes', 'my_remove_wp_seo_meta_box', 100000 ); } function my_remove_wp_seo_meta_box() { remove_meta_box( 'wpseo_meta', 'post', 'normal' ); } Notice the 100000 in the add_action, this makes sure that this is done after the WP SEO ...


5

Looking at the filter: $post_content = apply_filters( 'wpseo_pre_analysis_post_content', $post->post_content, $post ); it would be a matter of adding your fields content to string being analyzed. You have to do the get_field() part right, this is untested: add_filter( 'wpseo_pre_analysis_post_content', 'filter_yoasts_wpse_119879', 10, 2 ); function ...


4

ASCII characters will not cause any issues with search engines and they will be displayed properly. SEOmoz does this to avoid any chance of sql injection via its form fields.


4

You have introduced 2 additional problems by adding the jQuery from Google CDN. The admin interface needs jQuery called in no conflict mode so it won't interfere with the other scripts WordPress uses for the dashboard. The WordPress dashboard is not yet compatible with jQuery 1.5 thats why it was pulled from trunk right before 3.1 was released. See: ...


4

In the source code I see two og:description meta tags. The first and correct one seems to be coming from your Yoast WordPress SEO Plugin. The other one is outside the plugin's block, so I guess it's defined elsewhere. Check your theme if it includes that meta tag. If not, check your other plugins. Disable them one by one to find the culprit.


4

Try pasting this in a plugin or theme functions.php file, as per the WordPress SEO plugin (API Docs), by Yoast. if(function_exists('wpseo_use_page_analysis') && !current_user_can('administrator')){ add_filter('wpseo_use_page_analysis', '__return_false'); } To avoid any errors... This checks to make sure the function exists, before attempting ...


3

Yoast uses wp_head hook to output the meta description tag. Make sure you have this line in your <head>: <?php wp_head(); ?> For title tag, you can simplify the code by using one function call: <?php wp_title( '|', true, 'right' ); ?> The wp_title uses a filter (same name wp_title) to let users change the title tag. And Yoast uses ...


3

To add a page number regardless to any plugin … use filters. Do not change the plugin file. You cannot run updates other wise. Example: <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Add page number to title * Description: Adds <code> | Page $number</code> to the page title. * License: MIT * License URI: http://www.opensource....


3

Throw this into your functions.php: function clear_yoast_metadesc( $metadesc ) { return ''; } add_filter( 'wpseo_metadesc', 'clear_yoast_metadesc', 99, 1 ); If you set the $metadesc to empty like that, it won't be echoed. BTW, bulk editing is very hard on my to-do list, so you would be able to switch back completely :)


3

You will want to make use of Yoast SEO's "WPSEO_Frontend" class. To display the meta description field content, you could do the following: <?php if (class_exists('WPSEO_Frontend')) { echo WPSEO_Frontend::metadesc(false); } ?>


3

Solution: <?php $object = new WPSEO_Frontend(); echo $object->metadesc( false ); ?>


3

I don't think you are going to be able to do that using remove_action. The function argument in remove_action will not help you as the debug_marker() function was not the function that was used in the add_action() call. Yoast presumably has something like add_action( "wp_head", "head" ) in his code. So you can remove the "head" function, but debug_marker ...


3

Add the following code in the archive template loop to display Yoast SEO meta description for each post. echo get_post_meta(get_the_ID(), '_yoast_wpseo_metadesc', true);


3

This should hide it for everyone but the admin. If you run into any issues, you can use a plugin like Advanced Access Manager to get the job done. With that you will have more control of what each user level has access to. function hide_yoastseo() { if ( !current_user_can( 'administrator' ) ) : remove_action('admin_bar_menu', 'wpseo_admin_bar_menu',95); ...


3

Go to Admin > Settings > Permalinks and click save without altering anything "Sometimes resetting the permalink structure will quickly solve a 404 error from a recent change to your installation." See http://kb.yoast.com/article/77-my-sitemap-index-is-giving-a-404-error-what-should-i-do for further details


3

Filters should be returned even if your condition fails. You are currently just returning the output when your condition is met, not when it fails. return $string; at the end of each function should solve your issue. EXAMPLE add_filter('wpseo_canonical', 'listpagecanonical'); function listpagecanonical($string) { if (is_page(1)){ //I do my ...


3

You can use the exact same filter in your template files. If you do need it in functions.php for any reason (maybe you have some additional processing) then you can use your own custom filter. functions.php: function my_custom_authorpage_title( $title ) { // process ... return apply_filters( 'my_title', $title ); } add_filter( 'wpseo_title', '...


2

Seriously, I don't know why this thing keeps popping up but: it just works with single quotes, no need to change anything. Need proof? Ok, here we go: Search for "WordPress SEO plugin". Find my site, yoast.com, it'll be #1 in most cases. See the meta description showing? Click on the "Cached" link, then open the source for the cache. There it is, in full ...


2

Just rename the plugin dir through FTP and it'll deactivate. It's probably clashing with another plugin...


2

It is suppose to work this way. Joost's plugin only gives you a great tool for you to optimize your snippet. If you haven't done any optimizations whatsoever, like creating an awesome brief description of what your content is all about, Google will probably try to figure out what's the best bit of content by their own. Just a minor edit, Google just ...


2

I tracked the function calls in my theme (a child theme of Oenology by Chip Bennett) and wp-include that generate the links, found the home_url() function, and then wrote these functions for my site: function gregory_make_relative($url='') { return preg_replace( '#^https?://[^/]+/#iu', '/', $url, 1 ); } add_filter( 'home_url', 'gregory_make_relative', ...


2

Edit. Here's another solution to not mess with the edit slug button. The function get_sample_permalink_html in wp_admin/includes/post.php outputs the sample permalink and an edit button. It can be filtered like this: add_filter('get_sample_permalink_html','my_sample_permalink',10,2); function my_sample_permalink ($page_link,$id){ $page = get_page($id);...



Only top voted, non community-wiki answers of a minimum length are eligible