WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] more ignored in custom posts page (8 posts)

  1. jrodgers
    Member
    Posted 6 years ago #

    I have a wordpress set up so that my home page is static and all posts except cat1 posts are shown on page1, cat1 posts are shown on page16 but when i use the <!--more--> tag on cat1 posts it is ignored when displayed on the custom page, how can i correct this?

    tia

  2. jrodgers
    Member
    Posted 6 years ago #

    adding
    $more=0; before the loop corrects this

  3. thecoup
    Member
    Posted 5 years ago #

    jrodgers, I've tried adding $more=0 before the loop, but without any success. Are you using get_posts()?

    I'm using page.php. The page has a custom field that sets a related category. I'm grabbing posts for that category.
    It's working fine except for the more quicktag. Any suggestions?

    <?php if (isset ($relatedcat)) { // if page has related category
      $more = 0;
      global $post; $myposts = get_posts('numberposts=99&category='.$relatedcat.'&order=ASC');
      if($myposts) {
      foreach($myposts as $post) {
      setup_postdata($post);
    	?>

    full code: http://wordpress.pastebin.ca/1022004.

  4. jrodgers
    Member
    Posted 5 years ago #

    my code looks like this

    <?php
    query_posts('page_id='.$_GET['page_id']);
    $more = 0;
    ?>

  5. RachelAB
    Member
    Posted 5 years ago #

    I am still have trouble getting the more tag to work. I've tried setting the more variable to 0 and to 1. Neither works on a custom page that uses a plug in to collect various posts (see this page).

    Here's the whole code for the page (let's hope this posts):

    <?php /* Template Name: Page allowing More Tag */ ?>
    <?php get_header(); ?>
    <div id="content">
    <!-- This is using page-more.php -->
    <?php if (have_posts()) :  while (have_posts()) : the_post(); ?>
      <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
      <?php the_content(__('... read more here')); ?>
      <?php wp_link_pages(); ?>
      <?php edit_post_link(__('Edit'), '<p>', '</p>'); ?>
    <?php endwhile; endif; ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks!

  6. jrodgers
    Member
    Posted 5 years ago #

    try this

    <?php /* Template Name: Page allowing More Tag */ ?>
    <?php get_header(); ?>
    <div id="content">
    <!-- This is using page-more.php -->
    <?php
    query_posts();
    $more = 0;
    ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
    <?php the_content(__('... read more here')); ?>
    <?php wp_link_pages(); ?>
    <?php edit_post_link(__('Edit'), '<p>', '</p>'); ?>
    <?php endwhile; endif; ?>
    </div>
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

  7. thecoup
    Member
    Posted 5 years ago #

    jrodgers, thanks so much for your suggestion.

    It seems the more quicktag does not work with get_posts() even when using $more = 0.

    It does work with query_posts() with $more = 0 even if you use page.php.

    A note for people switching functions. Use category= with get_posts(). Use cat= with query_posts().

    Next challenge: get tags working on my related posts displayed below my page's content.

    Here's my query for posterity:

    <?php if (isset ($relatedcat)) { // if page has related category
     $query= 'numberposts=99&cat='. $relatedcat.'&orderby=date&order=ASC';
     query_posts($query); // run the query
     global $more; $more = 0;
     while (have_posts()) : the_post();
     setup_postdata($post);
    ?>
    <div class="post" >
  8. Xerotone
    Member
    Posted 5 years ago #

    $more = 0 did it for me. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic