How To Show Linked Pages In Word Press

In recent times, one of our customers asked us if there was a method to show related pages in its place of posts in Word Press. Before, we revealed you how to show associated posts in Word Press with or without plugin. In this article, we will demonstrate you how to show related pages in Word Press.

Showing Related Pages in Word Press Utilizing Plugin:

linked pages

The simple and easier method to show related pages in Word Press is by utilizinga plug-in. First of all you require to do is installed & activate the Yet another Related Posts Plug-in (YARPP) plugin. After start, you require to go to Settings » YARPP to configure the plug-in.

On the plugin’s settings page, scroll down to ‘Display selections for your website’ part. Under mechanically Display choice, you require to check ‘pages’ & leave posts & media unchecked. That is all, you can save your settings now & YARPP will begin showing related pages below page content on your Word Press website. Please note that YARPP along with a number of other Word Press plug-in is blocked by a few managed Word Press hosting givers due to its serious database usage. Another matter that you may face is that YARPP can’t look for database for text if your MySQL storage space engine is set to InnoDB.

Displaying Related Pages in Word Press without Plugin:

Before we show you how to show related pages without utilizing a plug-in, we want you to take a look at our article on the difference between Posts & Pages in Word Press. Most well-organized method to show related posts is by looking for tags or categories. However since Word Press pages don’t have tags or categories, we will first require allowing categories & tags for Word Press pages. To do that, all you require to do is install and activate, the Post Tags & Categories for Pages plugin. The plug-in works out of the box, so there are not settings for you to arrange. Upon start, it will only enable tags & categories for your Word Press pages.


01 function wpb_related_pages() {
02 $orig_post = $post;
03 global $post;
04 $tags = wp_get_post_tags($post->ID);
05 if ($tags) {
06 $tag_ids = array();
07 foreach($tags as $individual_tag)
08 $tag_ids[] = $individual_tag->term_id;
09 $args=array(
10 'post_type' => 'page',
11 'tag__in' => $tag_ids,
12 'post__not_in' => array($post->ID),
13 'posts_per_page'=>5
14 );
15 $my_query = new WP_Query( $args );
16 if( $my_query->have_posts() ) {
17 echo '<div id="relatedpages"><h3>Related Pages</h3><ul>';
18 while( $my_query->have_posts() ) {
19 $my_query->the_post(); ?>
20 <li><div class="relatedthumb"><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('thumb'); ?></a></div>
21 <div class="relatedcontent">
22 <h3><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></h3>
23 <?php the_time('M j, Y') ?>
24 </div>
25 </li>
26 <? }
27 echo '</ul></div>';
28 } else {
29 echo "No Related Pages Found:";
30 }
31 }
32 $post = $orig_post;
33 wp_reset_query();
34 }

Now you require editing a couple of pages you believe are related to every other & add tags. For instance, if you have a page about your corporation & an additional page for company’s the past, you can tag them both as about us. After you have added tags to a few pages, the next object you require to do is to add this code in your theme’s functions.php file or a website-specific plug-in. This code looks for tags related with a page & then runs a database inquiry to get pages with the comparable tags. To show the list of pages, you would require editing your page pattern. Most usually it is page.php or content-page.php file. Only add this line of code where you desire related pages to appear. This will show associated pages on any Word Press page. It will not seem very beautiful at first, so you will require adding a few CSS and styling it to match your theme.

Leave a Reply

Your email address will not be published. Required fields are marked *