WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Sidebar Content Issue only for Pages (7 posts)

  1. bcreighton
    Member
    Posted 6 years ago #

    Hi,

    My more link isn't behaving properly in the sidebar when on a Page. Posts work perfectly. I'm using query_posts to pull in a bit of content and the more link is rendering as an empty span where it should be. It also doesn't truncate it at the more link and shows the full text.

    Why would Pages behave differently than Posts? I'm also using a custom Page template if that should make a difference...

    Thanks.

  2. bcreighton
    Member
    Posted 6 years ago #

    The code for the sidebar content looks like this:

    <?php query_posts('cat=6&showposts=1 ');	?>
            <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
            <div class="journal-body" id="post-<?php the_ID(); ?>">
              <h4>
                <?php the_title(); ?>
              </h4>
              <?php the_content('Read more &raquo;');?>
            </div>
            <?php endwhile; ?>
            <?php else : ?>
            <p>Not Found</p>
            <?php endif; ?>
  3. moshu
    Member
    Posted 6 years ago #

    The "more" never worked and doesn't work on Pages. Since there is no "multi-Page" view in WP (as opposed to multi-post view) - no need for it.

  4. bcreighton
    Member
    Posted 6 years ago #

    But isn't page content, it's post content that I'm pulling in the sidebar. The sidebar just happens to be included on the page...

  5. bcreighton
    Member
    Posted 6 years ago #

    Ah, but thank you for linking to the page post. I figured it out, you just need to add:

    global $more;
    $more = 0;

    before the loop.

    If you're using the <!-- more --> quicktag to place things below the fold in your posts, you'll want to include the global variable $more and set it to zero (as shown in the code above). Otherwise, the entire post will print out on your blog's main page.

  6. moshu
    Member
    Posted 6 years ago #

    The sidebar just happens to be included on the page...
    That's enough! WP "knows" it is on a Page... otherwise all those
    if is_page...
    conditionals would never work.

  7. bcreighton
    Member
    Posted 6 years ago #

    Gotcha. At least WP provides a work-around for people pulling in post content on pages...

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags