Support » Fixing WordPress » More tag ignored on home page

  • Resolved heriz


    So my home page is set to display according to a template file as per Moshu’s superb Static Frontpage with Dynamic Content tutorial. It is set up to pull only the ‘news’ category posts, using a second loop. Here is the code for the second loop:

    <?php $temp_query = $wp_query; ?>
    <?php query_posts(‘category_name=news&showposts=8’); ?>
    <?php while (have_posts()) : ?> <?php the_post(); ?>
    <div class=”post” id=”post-<?php the_ID(); ?>”> <div class=”post-title”>
    <h3>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></h3>

    <div class=”entry”>
    <p><?php the_content(‘(Read on) »’); ?></p>
    <span class=”post-date”><?php the_time(‘l F j, Y’); ?></span>
    <span class=”post-comments-home”><?php comments_popup_link(‘No comments yet’, ‘1 Comment »’, ‘% Comments »’); ?></span>


    The only problem is that my ‘more’ tags are removed. As I really only want excerpts (but with the ‘read more’ option as opposed to the standard no-linked […] when using the_excerpt), this is frustrating.


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

    Under the template name does nothing, and including it within the php template tags

    /*Template Name: Main*/
    global $more;
    $more = 0;

    breaks it completely. (Bear in mind I’m a novice in PHP, but this was suggested in a tutorial so it ought to work).

    Any suggestions on how to fix this please?


Viewing 15 replies - 1 through 15 (of 19 total)
  • Solved it.


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

    code needs to be placed under the “entry” div tag in the second loop.

    Sorry to keep starting support questions then solving them myself! Hopefully this will help someone…

    Just blame Moshu, that’s what the rest of us do 😉

    Can somebody explain me why is <!--More--> tag ignored on home (front) page? (is_home() == TRUE)?

    It’s very inconsistent behaviour and for me it was difficult to resolve why my posts are not cutted after <!--More--> on home page post listing.

    If you understand the reasons, please consider explaint it to following Codex pages where is the_content() and excerpt described.


    Can somebody explain me please, why <!–More–> tag isn’t working here:

    <?php rewind_posts();
    global $more;
    $more = 0;
    $my_query = new WP_Query(‘order=asc&showposts=500’);
    while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID; ?>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <h2>” rel=”bookmark” title=” <?php the_title_attribute(); ?>”><?php the_title(); ?></h2>
    <small><?php the_time(‘F jS, Y’) ?> <!– by <?php the_author() ?> –></small>
    <div class=”entry”>
    <?php the_content(‘Read the rest of this entry »’); ?>
    <?php endwhile; ?>

    I receive the whole text and something like this

    <p><span id=”more-45″></span></p>

    but not more-tag.
    (i found that here:

    heriz – THANK YOU!!! Trying to solve this problem – and your post did it – greatly appreciated;-) I placed under the entry in the loop on the template page – worked like a charm!

    Thanks for posting this, I was looking everywhere for a fix to why the more-tag didn’t work and only when I palced the “global $more..” part further down in the loop did it work.

    good grief, for the LIFE of me i cannot get this to work!

    creating a new page, using a custom templte like this:

    Template Name: allowcomments-template
    <?php get_header(); ?>
    	<div id="wordpress-content">
    <h2><?php the_title(); ?></h2>
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    				<div class="entry">
    					<?php the_content('Read the rest of this entry &raquo;'); ?>
                    <?php global $more;
    $more = 0; ?>
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    <?php comments_template(); ?>
    		<?php endwhile; endif; ?>
            <br clear="all" />
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    <?php //get_sidebar(); ?>
    <?php get_footer(); ?>

    and it doesn’t work.
    It DOES work on the default index page if i place a long post. but not if i add
    to a Page.

    Any help appreciated!!

    The problem is that you are putting the code in the wrong place. You are putting the code after the call to write the content instead of before. Try:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
      <?php global $more; $more = 0; ?>
        <div class="post" id="post-<?php the_ID(); ?>">
    	<div class="entry">
    	 <?php the_content('Read the rest of this entry &raquo;'); ?>

    Move the code for the global more before the call to the_content (‘Read the rest…

    What you are doing is setting the $more variable BEFORE the WordPress Loop uses it.

    What you were doing was setting the variable AFTER the WordPress Loop wrote the_content. I hope this makes sense.

    I like to put my global call immediately after theif (have_posts()) line, but some folks say it works better in the entry division. That seems to produce unnecessary repeated code calls. But either way should work. Sorry I didn’t come across this post sooner.

    So my code looks like this:

    function the_content('more_link_text', $stripteaser = 0, 'more_file = ''') {
    	$content = get_the_content($more_link_text);
    	$content = apply_filters('the_content', $content);
    	$content = str_replace(']]>', ']]>', $content);
    	echo $content;
    function get_the_content($more_link_text = null, $stripteaser = 0, $more_file = '') {
    	global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
    	if ( null === $more_link_text )
    		$more_link_text = __( '(more...)' );
    	$output = '';

    What does null mean? Where exactly do I enter global more using php because none of this has php tags. This is in the wp-includes/post-template.php file. Please help because I am tired of using excerpt editor.

    Hi all. I found this thread very informative and I already solved some of my problems. However, I have a problem I do not know how to solve. The WP blog is displaying the excerpt correctly (using the <!–more–> tag), except when I click on the post name to see it it only gives me the excerpt again, not the entire text. I hope I am not double, triple or quadruple-posting the same question but I was not able to find an answer in the support forum. Here is the index.php code:

    <?php global $more; $more = 0; ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    	 <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    	<div class="meta"><?php _e("Posted by"); ?> <?php the_author() ?> | <?php the_category(',') ?> | <?php the_time('l j F Y'); ?> <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>
    	<div class="storycontent">
    <?php the_excerpt(__('(more...)'));?>
    	<div class="feedback">
                <?php wp_link_pages(); ?>
                <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>
    <?php comments_template(); // Get wp-comments.php template ?>
    <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <?php posts_nav_link(' — ', __('&laquo; Previous Page'), __('Next Page &raquo;')); ?>
    <?php get_footer(); ?>

    Why are you using the_excerpt? Use the_content instead.

    Thank you for pointing that out Otto. I changed it to <?php the_content(__('(more...)'));?> and it worked! With one problem though. Now, it seems to have screwed up the layout of the front page (displays the text properly excerpted). I have no idea why, because when I click on “more” to display the entire post, everything is displayed and laid out properly.

    So it is either the previous situation where the layout is correct but the entire post is not showing, or the other way around. For the past two hours I have been reading the WP tutorials and searching the forum for pointers and still have no idea why. Any help will be much appreciated.

    What file is the_content in?

    We really can’t help you with the layout without a link to the actual page, to see what it’s doing.

    The URL is: Oddly enough (to me) it seems to display correctly in IE, not in FF.

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘More tag ignored on home page’ is closed to new replies.