Show Alternate Content When WordPress More Tag Is Missing

Quick tip. It’s a wordpress tip day for bloggers or webmasters running a self-hosted wordpress installation.

One of my favourite wordpress quick-tags is the more tag. Its basic function is to spilt your articles or blog post entries in parts so that only a certain part of it is visible via the Home, Category or Archive pages of your site and thus any visitor interested in getting the whole gist, has to click through to the full article.

The more tag also helps SEO wise to evade any possible Google duplicate content penalties but then it all depends on how your wordpress theme is coded. Some themes don’t need the more tag to stop them from showing full articles on the Home, Archive and Category pages.

Now aside this basic function, the more tag could also be used to show any text and image in the form of adverts etc in between long articles.

This is easily done using the code below which must be pasted into the function.php file of your active wordpress theme. Create a backup of function.php before doing this as if you get the pasting wrong, your site will stop showing content and you might even have a problem navigating the wordpress dashboard – backend too.


add_filter('the_content', 'adds_block');
function adds_block($content){
if (is_single())
global $post;
$thePostID = $post->ID; $new_insert = '' ;
return str_replace($new_insert, my_ad(), $content);
function my_ad(){

Now, in some cases such as short articles below 400 words, you would forego the use of the more tag but still want to show that extra code somewhere in the article.


How To Show Content When There’s No More Tag In WordPress Page


Simply copy and paste the code below provided by member 3Stripe into the single.php file of your wordpress theme.


<?php if(strstr($post->post_content,'<!--more-->')) { echo 'show this when there's a more tag'; } else { echo 'show this when there's NO more tag'; } ?>


Save changes and test to see if it works right.

Unfortunately after much testing, I think it’s safe to say that this doesn’t work in the sidebar or anywhere else except within the article/content column which is basically run by single.php.

Questions and comments are welcome as always should you run into difficulties or whatever ;)

Reviewer's Rating!
Leave Your Own Rating!
[Total: 0 Average: 0]

You’ll also like:

  1. How To Fix AMP Script Appears More Than Once In The Document
  2. How To Shop EVERYTHING On Amazon US/UK Via DHL eShop
  3. How To Make YouTube Vimeo Embeds Responsive In HTML
  4. How To Fix Leverage Browser Caching For Third Party JavaScript/CSS
  5. My Top 10 Must Have BlackBerry Apps

Please share this article to help others. Thanks