• Resolved bozack

    (@bozack)


    hi i’ve figured out how to post entries from a specific category on a page. but i’m having a couple problems.

    1. if you notice, the entries post twice on the page. how do i have it so it only posts once?

    2. the more link does not show up, and it shows the entire entry. how do i have it so that it shows like how it does on the index page, with the “click here for more” option.

    the page can be viewed here : https://www.black-rap.com/blog/?page_id=24

    and here is the code for the page.

    <div id="brtv-title"> <img src="https://black-rap.com/brtv-title.gif"> </div> 
    
    <?php query_posts('cat=4&amp;showposts=10'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <div class="post-item">
          <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
          <p class="meta">posted by <?php the_author();?> on <? the_date();?> in <?php the_category(', '); ?>
    
    <?php the_content('Click here to read more...');?>
    <div class="numComments">
    <a href="<?php comments_link(); ?>"><?php comments_number('0 comments', '1 comment', '% comments'); ?></a>
    </div><!--end numComments-->
        </div><!--end post-item-->
    <?php endwhile;?>

    if you can review it, and find whats wrong,
    it would be greatly appreciated!
    thanks!

Viewing 12 replies - 1 through 12 (of 12 total)
  • I’m not seeing duplicates.

    Thread Starter bozack

    (@bozack)

    really?
    cause i’m seeing duplicate posts at the end of the page in both firefox and safari.

    the duplicate posts, aren’t using the .post-item css for some reason either. =S

    Okay see what you mean.

    Guess you need to post your complete PAGE Template in a pastebin and report the link back here.

    Thread Starter bozack

    (@bozack)

    here is the code for my page.php

    <?php get_header(); ?>
    <div id="main">
      <div id="primary">
      <div id="page_content2">
        <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    
          <h3><a href="<?php the_permalink(); ?>">
          </a></h3>
    
          <?php the_content('Click here to read more...');?>
    
        <?php endwhile; ?>
        <?php else : ?>
        <p>No Results</p>
        <?php endif; ?>
        </div><!--page_content2-->
      </div>  <!--end primary-->
      <?php get_sidebar();?>
    </div>
    <!--end main-->
    <?php get_footer();?>

    let me know what you find!
    thanks ??

    Is there a reason a normal Category Archive wouldn’t work so you don’t need to create a specific page template?

    If the issue is getting a link in a menu to a page that contains posts for a specific category look at:
    How to easily display links to both Pages and Categories in the blog navigation header?

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    Thread Starter bozack

    (@bozack)

    well i’d like it so i can add html to the top of the page (ie. catagory title header and description)

    if i can do that with out creating a seperate page that would help.

    Yes, just use the Category Templates ability.

    Thread Starter bozack

    (@bozack)

    that actually works now…..kinda….
    i notice now for some reason when i click on the next page,
    it still shows the same blog entries in page 1.
    why is that?

    https://www.black-rap.com/blog/category/brtv/

    Thread Starter bozack

    (@bozack)

    oh yeah here’s the code that i used!

    <?php get_header(); ?>
    <div id="main">
      <div id="primary">
      <div class="title">
      <img src="<?php echo bloginfo('template_directory') . '/img/brtv-title.gif' ?>" />
      </div>
      <?php query_posts('cat=4&amp;showposts='.get_option('posts_per_page')); ?>
        <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
        <div class="post-item">
          <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
          <p class="meta">posted by <?php the_author();?> on <? the_date();?> in <?php the_category(', '); ?></p>
    <?php the_content('Click here to read more...');?>
    <div class="numComments">
    <a href="<?php comments_link(); ?>"><?php comments_number('0 comments', '1 comment', '% comments'); ?></a>
    
    </div><!--end numComments-->
        </div><!--end post-item-->
        <?php endwhile; ?>
        <?php else : ?>
        <p>No Results</p>
        <?php endif; ?>
    
        <div id="morePrev">
        <?php next_posts_link('Next...'); ?>
        <?php previous_posts_link('Previous...'); ?>
        </div><!--end morePrev-->
      </div><!--end primary-->
    
    <?php get_sidebar();?>
    </div><!--end main-->
    <?php get_footer();?>
    Thread Starter bozack

    (@bozack)

    bump!

    pagination appears to be working correctly when I looked at it. Try clearing your browser cache if you’re still seeing the errors.

    Thread Starter bozack

    (@bozack)

    thanks brainycat!
    i actually figured it out.
    i had a line of code before the loop that was having it happen.
    i took out `<?php query_posts(‘cat=4showposts=’.get_option(‘posts_per_page’)); ?>
    `
    and now its working perfectly!
    thanks for checking it out though!

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘posts from categories posting twice’ is closed to new replies.