How to call WordPress related articles without plug-in

888u

Last update at :2024-06-20,Edit by888u

Snails shared previously "Reason for giving up using the WordPress Related Posts plug-in". I originally wanted to use another "Yet Another Related Posts Plugin" plug-in. There are many foreign users, and It is very popular, and Matt Cutts also recommended this related article plug-in as the first choice in his blog post. But after using it, I found that everything else is pretty good, except that the position cannot be customized. It displays directly at the bottom of the article by default. If the article has content added at the bottom of the template, the content will be under the call. So I gave up using plug-ins and directly implemented the method of calling WordPress related articles without plug-ins.

The first step is to edit the following code where you need to add relevant content calls:

You may like the following:

    ID);if ($post_tags) {foreach ($post_tags as $tag){$tag_list [] .= $tag->term_id;}$post_tag = $tag_list[ mt_rand(0, count($tag_list) – 1) ];$args = array(\\'tag__in\\' => array($post_tag) ,\\'category__not_in\\' => array(NULL),\\'post__not_in\\' => array($post->ID),\\'showposts\\' => 6,\\'caller_get_posts\\ ' => 1);query_posts($args);if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); >
  • ID);if( $ashu_cats ){$args = array(\\'category__in\\' => array ( $ashu_cats[0] ),\\'post__not_in\\' => array( $post->ID ),\\'showposts\\' => 6,\\'caller_get_posts\\' => 1);query_posts ($args);if( have_posts()):while(have_posts()):the_post();update_post_caches($posts);>

Step 2: Add styles

If you feel the interface is good after adding the above code, just use it directly. If not, you need to use the following style.

/* post-relate */.post-relate{padding:10px 5px;color:#888;}.post-relate h3{margin:0;line-height:22px;Verdana;font-size:14px; }.post-relate ul{margin:5px 15px;padding:0px 5px;}.post-relate li{margin:0px 0px;padding:2px 0px 2px;}

The style also needs to be adjusted according to your own needs. In this way, we can achieve the effect without plug-ins and reduce the memory consumption of WP. Try not to use plug-ins if possible.

Recommended site searches: mobile proxy ip, pw domain name, free ip, US server defense, cheap virtual host, the cheapest dual-line space, how to cancel domain name registration, ip detailed address query, free foreign servers, asp website space ,

How to call WordPress related articles without plug-in

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码