👋🏼Welcome to my WP-Host blog where I am excited to share my knowledge and expertise on WordPress hosting and website construction tutorials with you. Let’s connect and learn from each other! You can reach me at info@yrshare.com.
Add automatic tag tags to the website (improve SEO optimization effect): Continue to share the wordpress website building tutorial. Good use of tag tags is of great help to website SEO optimization. This article will share with you a usage of tag tags. If used well, it can further improve the SEO optimization effect of Google.
We all know that website SEO optimization is mainly to optimize content, external links, and internal links, and tag tags are very good internal links in wordpress websites.
By default, the tag label of the website will appear at the bottom of the article, but the effect may not be very good if this is the case. The tutorial in this article is to teach you to use tags to make a website internal link, and it is an automatic internal link, which does not require us Add it manually.
Here’s how to start sharing:
Table of Contents
1. Use plugins
Auto Tag Links
https://wordpress.org/plugins/auto-tag-links/
In fact, the tag internal link is not a high-end function. There are many plug-ins that can realize this function, so it is the simplest and most convenient to use the plug-in to realize the tag internal link, such as Auto Tag Links. After installation, you can set and save it. convenient.
2. Use the code
Some people may worry that the use of plug-ins will affect the opening speed of the website. Although one or two plug-ins alone do not have a great impact on the opening speed of the website, there are indeed ways to not use plug-ins. Let me share with you a piece of code to realize the internal link of the label:
//Automatically add tags to internal links
$match_num_from = 1; //Indicates that the tag appears at least once to add an automatic internal link
$match_num_to = 1; //Indicates how many internal links can be added to a tag in the article at most, and it is recommended to set it up to 3 times
add_filter('the_content','tag_link',1);
function tag_sort($a, $b){
if ( $a->name == $b->name ) return 0;
return ( strlen($a->name) > strlen($b->name) ) ? -1 : 1;
}
function tag_link($content){
global $match_num_from,$match_num_to;
$posttags = get_the_tags();
if ($posttags) {
usort($posttags, "tag_sort");
foreach($posttags as $tag) {
$link = get_tag_link($tag->term_id);
$keyword = $tag->name;
$cleankeyword = stripslashes($keyword);
$url = "<a href=\"$link\" title=\"".str_replace('%s',addcslashes($cleankeyword, '$'),__('View all posts in %s'))."\"";
$url .= ' target="_blank"';
$url .= ">".addcslashes($cleankeyword, '$')."</a>";
$limit = rand($match_num_from,$match_num_to);
$content = preg_replace( '|(<a[^>]+>)(.*)('.$ex_word.')(.*)(</a[^>]*>)|U'.$case, '$1$2%&&&&&%$4$5', $content);
$content = preg_replace( '|(<img)(.*?)('.$ex_word.')(.*?)(>)|U'.$case, '$1$2%&&&&&%$4$5', $content);
$cleankeyword = preg_quote($cleankeyword,'\'');
$regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s' . $case;
$content = preg_replace($regEx,$url,$content,$limit);
$content = str_replace( '%&&&&&%', stripslashes($ex_word), $content);
}
}
return $content;
}
Add the above code to the functions.php of the current wordpress theme and save it, then refresh the website to see the effect.
3. Precautions for label internal links
The implementation method of the automatic label internal link shared in this article is not suitable for all websites. You need to choose whether to use it according to the situation. For example, your website has little content, not many labels, and there are few contents under the same label, so 【WP-Host/悦然wordpress建站】 It is not recommended that you use the automatic label internal link function. At the same time, the content quality of the website is also very important. It is useless to add more label internal links to poor quality content.
The automatic label internal link function is more suitable for websites with a lot of content, because too much content is not suitable for manually adding internal links, and the efficiency is too low. If your website does not have much content, my suggestion is to add internal links manually, and label internal links are not the best internal links. The best internal links are to add relevant internal links according to the content of the article, such as Can link to an article.
Summarize
Whether it is wordpress site building or SEO optimization, content is still the key. The automatic label internal link can play an icing on the cake effect, but the most important thing is to do a good job in the content foundation.
【WordPress Hosting / 悦然wordpress建站】I am a WordPress hobby from China, and I like to communicate with friends from all over the world to learn WordPress website building and maintenance related knowledge.