php 钩子禁用Yoast SEO插件功能和管理屏幕控制。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 钩子禁用Yoast SEO插件功能和管理屏幕控制。相关的知识,希望对你有一定的参考价值。

<?php
/*******************************
 =Yoast SEO Hooks (includes Premium)
  ******************************/
 /* Remove default redirects feature, for posts and term.
  * @link https://kb.yoast.com/kb/how-to-disable-automatic-redirects/
  */
add_filter('wpseo_premium_post_redirect_slug_change', '__return_true' );
add_filter('wpseo_premium_term_redirect_slug_change', '__return_true' );

/* Use Yoast SEO's Primary Category feature only on Categories. */
function my_yoast_prime_cats( $all_taxonomies ) {
    $args = array( 'name' => 'category' );
    $all_taxonomies = get_taxonomies( $args, 'objects' );
 
    return $all_taxonomies;
}
add_filter('wpseo_primary_term_taxonomies', 'my_yoast_prime_cats' );

/**
 * Disable the WPSEO v3.1+ Primary Category feature.
 */
// add_filter( 'wpseo_primary_term_taxonomies', array( 'custom-tax' ) );

/* Remove the Yoast SEO columns from admin lists. */
function my_remove_yoast_cols( $columns ) {
    unset( $columns['wpseo-title'] );
    unset( $columns['wpseo-metadesc'] );
    unset( $columns['wpseo-focuskw'] );
    unset( $columns['wpseo-links'] );
    unset( $columns['wpseo-score'] );
    unset( $columns['wpseo-score-readability'] );

    return $columns;
}
add_filter ( 'manage_edit-post_columns', 'my_remove_yoast_cols' );
add_filter ( 'manage_edit-page_columns', 'my_remove_yoast_cols' );

/* Remove Yoast SEO filter dropdowns on All Posts|Pages screens (e.g., "All SEO Scores"). */
function hmy_remove_yoast_posts_filters() {
    global $wpseo_meta_columns;

    if ( $wpseo_meta_columns ) { // Remove "All SEO Scores" and "All Readability Scores".
        remove_action( 'restrict_manage_posts', array( $wpseo_meta_columns, 'posts_filter_dropdown' ) );
        remove_action( 'restrict_manage_posts', array( $wpseo_meta_columns, 'posts_filter_dropdown_readability' ) );
    }
}
add_action( 'admin_init', 'my_remove_yoast_posts_filters', 20 );

以上是关于php 钩子禁用Yoast SEO插件功能和管理屏幕控制。的主要内容,如果未能解决你的问题,请参考以下文章

php 禁用Yoast SEO主要类别功能

php 禁用Yoast SEO主要类别功能

php 使用Yoast SEO Analyis插件时,将ACF字段添加到Yoast SEO权重中

php 覆盖面包屑 - Yoast SEO WordPress插件

php Wordpress yoast seo插件,为自定义URL生成自定义站点地图

php Wordpress yoast seo插件,为自定义URL生成自定义站点地图