Saturday 30 September 2017

HOW TO CHANGE PAGE 404 WITH RECENT POST

From most of you while looking for articles on google of course also often find the url or the address of a website that when you click the url it turns out that page is not there or there is a 404 error message, Of course it is very annoying for everyone, especially the article in the search it's really needed. If you as a blog owner would not be separated from this 404 url.

Because we as a blogger can not escape from the dead url or 404, then twordpress with Recent post or last post, so that the visitors who already upset with what the search is not found, we replace it with a list of the last post from our blog, thus allowing visitors will not immediately leave blog, but reading other posts.
 PAGE 404 
o treat visitors who already come from search engines, then we must treat it by changing it to another page more interesting. In this article I will give a tutorial to change the page not found 404

Basically wordpress theme at bekali page 404 by default is like the picture below:

page not found 404 To replace it simply search first 404.php file in your wordpress theme, if you have met and open it and paste the following code under <? php get_search_form ();?>
<ul>
  <?php $the_query = new WP_Query( 'showposts=5' ); ?>
  <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
  <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
  <li><?php echo substr(strip_tags($post->post_content), 0, 250);?></li>
  <?php endwhile;?>
</ul>
Note: in the script show showposts = 5 if you want to add or subtract the 5th rate change to your liking. and to change the number of characters in the display change number 250.