Wordpress replace meta description

后端 未结 3 881
我在风中等你
我在风中等你 2021-01-15 06:04

I need to replace the existing generated by wp_head() function in header.php with a custom meta description. The informatio

3条回答
  •  不知归路
    2021-01-15 06:38

    The Description Meta tag is generally handled by the template header (header.php) or by a Plugin that is adding the description to the site (Such as SEO Title Tag). Since you are getting a duplicate description, you should check for plugins that are outputting a description tag.

    For other annoying meta tags and other things put in the header, you can use the remove_action() function in the functions.php file of your template to do this and can look at the documentation here: https://codex.wordpress.org/Function_Reference/remove_action

    I do something similar for a WP site I run and needed to remove every single meta tag that goes into the head and here is the code that I have at the bottom of my functions.php file to do it:

    // Remove Meta Tags that are Unneeded
    remove_action('wp_head','feed_links_extra', 3);
    remove_action('wp_head','rsd_link');
    remove_action('wp_head','feed_links', 2);
    remove_action('wp_head','wlwmanifest_link');
    remove_action('wp_head','index_rel_link');
    remove_action('wp_head','parent_post_rel_link', 10, 0);
    remove_action('wp_head','start_post_rel_link', 10, 0);
    remove_action('wp_head','adjacent_posts_rel_link', 10, 0);
    remove_action('wp_head','noindex');
    remove_action('wp_head','wp_generator');
    remove_action('wp_head','rel_canonical');
    remove_action('wp_head', 'wp_shortlink_wp_head');
    

    Obviously, only use the ones you need! I had trouble finding a list of all the functions for the meta-tags so I wanted to include all of the ones I used.

提交回复
热议问题