WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] More Link Missing on Custom Page template (6 posts)

  1. bodjiang
    Member
    Posted 3 years ago #

    Hi all,

    I have create page template "news.php", with template name "news". To display basically all the posts I have.

    The posts on this page doesn't show my custom "read more" link, also shows the full post rather than excerpt,(I had insert the "read-more" quick tag for each post). where the archive and category page shows them fine.

    Heres are my template structure:

    home.php
    index.php
    page.php
    single.php
    news.php (custom template)

    Here are the code for my index.php loop

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
            <!-- begin post -->
            <div class="blogPost">
              div class="date"><?php the_time('M') ?><br /><span><?php the_time('j') ?></span></div>
    	    <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    	   <div class="meta">
    	    By <span class="author"><?php the_author_link(); ?></span>  //   <?php the_category(', ') ?>   //   <?php comments_popup_link('No Comments', '1 Comment ', '% Comments'); ?>
    		 </div>
    	 <?php the_content(__('read more')); ?>
    	</div>

    Here are my news template loop:

    <?php query_posts('');
    		if (have_posts()) : while (have_posts()) : the_post(); ?>
    
            <!-- begin post -->
            <div class="blogPost">
                <div class="date"><?php the_time('M') ?><br /><span><?php the_time('j') ?></span></div>
    	       <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
    	     <div class="meta">
    		By <span class="author"><?php the_author_link(); ?></span>  //   <?php the_category(', ') ?>   //   <?php comments_popup_link('No Comments', '1 Comment ', '% Comments'); ?>
    	</div>
    	<?php the_content(); ?>
    </div>

    I was hoping someone can help me here.

    Many thanks

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

  3. cinematic
    Member
    Posted 3 years ago #

    seems to be obvioous :)

    your index.php

    <?php the_content(__('read more')); ?>

    your news-template

    <?php the_content(); ?>

  4. bodjiang
    Member
    Posted 3 years ago #

    seems to be obvioous :)

    Oops, I didn't update this post, I've been doing some testing myself, but no, I've tried to <?php the_content(__('read more')); ?> on my news-template, but it didn't work, appear to be the same problem.

  5. keesiemeijer
    moderator
    Posted 3 years ago #

    did you put this before the_content() as in the link alchymyth gave you?

    <?php
    global $more;
    $more = 0;
    ?>
    //The code must be inserted ahead of the call to the content
    <?php the_content('read more'); ?>
  6. bodjiang
    Member
    Posted 3 years ago #

    It's works with

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

    How Could I miss that, Thank you Keesiemeijer and alchymyth.

    Thank You.

Topic Closed

This topic has been closed to new replies.

About this Topic