Dude, Where’s My More Tag?

I ran into an interesting dilemma today in WordPress where the <!--more--> tag was not displaying on some posts. After doing a little digging around in the WordPress Codex I finally came across the solution to my problem, and would like to share it with you today! The secret is pretty simple actually, but it’s something that may trip up developers unless they have a real in-depth knowledge of WordPress and its functions.

According to the WordPress Codex, “The <!--more--> quicktag will not operate and is ignored in Templates, such as single.php, where just one post is displayed.”

So that’s what I’d been doing wrong! I had made a copy of the front-page.php and turned it into a template for an individual page (page-4108.php), and while the <!--more--!> links appeared in the front-page.php, they simply were not appearing in my page-4108.php template which was, to the digit, an exact duplicate of front-page.php.

Well that’s just great…but there’s got to be a work-around, right?! Thankfully, there is! It comes to us in the form of the global variable, $more. The fix is actually quite simple: before you call the_content();, just add the global variable $more and set it to 0…like this:

<?php global $more;
$more = 0; ?>

Now, when you go to load your page, you should see the “Read More” link wherever you placed the <!--more--> in your post body! A simple fix to an annoying problem, but hopefully this has saved you several hours of banging your head up against the wall and flipping back and forth between two identical files trying to figure out where you went wrong and why the universe chose today to pick on you!