• I wish to receive some help if I could to solve what could be a straight-forward problem. I have basically created a template, attached it to a WordPress page and it’s my news section and it runs like a simple blog. However:

    – Selecting an individual post by clicking the title does not show that post solely. It duplicates itself over and over when scrolling down.

    Is it conflicting with the main single.php file? I have had to implement a separate loop apart from the main loop which handles the rest of the website.

Viewing 15 replies - 1 through 15 (of 15 total)
  • Sounds like there is a problem in your custom template file itself. If you dropped a copy of the file into the WordPress pastebin and posted the pastebin url here, someone might be able to spot the problem and suggest a solution.

    Thread Starter mhuynh55

    (@mhuynh55)

    Cheers for the reply. The pastebin url is located here: https://wordpress.pastebin.com/51ny2Cyt

    Thread Starter mhuynh55

    (@mhuynh55)

    So basically what I have done is that WordPress Page with that custom template attached calls for a category with specific wordpress posts in it. But yes, the only problem I am encountering is the fact when you click on one of the posts, it should only show that post’s content only, but it doesn;t.

    What link are you using to get to the single post? Your post titles aren’t links. any chance of a link to a page using this template?

    Thread Starter mhuynh55

    (@mhuynh55)

    Oh I’m sorry, but this is what I had previously to control the problem:

    <?php post_class() ?> id="post-<?php the_ID(); ?>">
    				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    Why aren’t you using that in your custom template?

    Thread Starter mhuynh55

    (@mhuynh55)

    This is what happens if I implement it: link

    Thread Starter mhuynh55

    (@mhuynh55)

    I’ve tried to implement that (I quickly had to revert because it didn’t work). Selecting a single post still spits out multiple duplicates.

    I quickly had to revert because it didn’t work

    What happened? The problem might in another template – header.php, for example

    Thread Starter mhuynh55

    (@mhuynh55)

    The display of the page was fine but if you a link the post title and select it to view that post only, it still duplicates that post down the page, instead of showing just that one post.

    In that case, it sounds like the issue is in your single.php template file.

    Thread Starter mhuynh55

    (@mhuynh55)

    I would appreciate for further help. This is my single.php file:

    <div id="content">
    
      <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
          <div class="post" id="post-<?php the_ID(); ?>">
    <div style="float:right;  color: #242424; font-weight:bold; font-size: 12px; text-transform: uppercase; font-family: 'Courier New', sans-serif;"><?php
    $category = get_the_category();
    echo $category[0]->cat_name;
    ?></div>
            <div class="entry">
    
         <a class="posttitlelink" href="<?php echo get_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
    <?php echo get_post_meta($post->ID, 'Photography by', true); ?>
              <?php the_content('<p class="serif">Read the rest of this entry &raquo;</p>'); ?>
              <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    <span class="date"><?php the_date(); ?></span>
    
            </div>
    
    </div>
    
    <?php if(is_single()) { // single-view navigation ?>
    	<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<?php previous_post_link(); ?> | <?php next_post_link(); ?>
    	<?php endwhile; endif; ?>
    <?php } else { // archive view navigation ?>
    		<?php posts_nav_link(); ?>
    <?php } ?>
    
        <?php endwhile; ?>
      <?php else: ?>
        <h2 class="posttitle center">Not found.</h2>
        <p>Sorry, no posts matched your criteria.</p>
      <?php endif; ?>
    
        </div>
    <?php get_sidebar(); ?>
    <div style="clear:both;"></div>
    <?php get_footer(); ?>
    Thread Starter mhuynh55

    (@mhuynh55)

    Is it clashing with the way I have set up the template page?

    You got 2 loops in that template file!

    Try replacing:

    <?php if(is_single()) { // single-view navigation ?>
    	<?php $posts = query_posts($query_string); if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<?php previous_post_link(); ?> | <?php next_post_link(); ?>
    	<?php endwhile; endif; ?>
    <?php } else { // archive view navigation ?>
    		<?php posts_nav_link(); ?>
    <?php } ?>

    with:

    <?php previous_post_link(); ?> | <?php next_post_link(); ?>

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘Display problems with blog within main website’ is closed to new replies.