• wstewart1

    (@wstewart1)


    I am working on my very first theme and it isn’t going well.

    The index page works great, but when I view a single entry, I run into problems. It sees the title, keywords and everything else properly, it just won’t display the text of the entry. I have tried everything from the default theme coding to my own homemade brew and still can’t get a solution.

    I know it is seeing the file because it displays the content of the <title> tag properly.

    My site: https://www.williamstewart.org

    Any help would be greatly appreciated!

    Here’s the code I’m using:

    <?php get_header(); ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>

    <h1><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h1>

    <span class="vitaldetails"><?php the_time('F d, Y'); ?> | <a href="<?php comments_link(); ?>"><?php comments_number('0 comments','1 comment','% comments'); ?></a><?php edit_post_link('Edit','(',')'); ?></span>

    <div class="mainlefthome">

    <?php the_content();?>

    </div>

    <?php endwhile; else: ?>

    <h1>File not found</h1>
    <p>Whoops! This file cannot be found.</p>

    <?php endif; ?>

    <!-- /content -->

    <?php get_footer(); ?>

Viewing 11 replies - 1 through 11 (of 11 total)
  • Ajay

    (@ajay)

    I use:

    <!--- middle (posts) column content begin -->
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    <div class=&quot;post&quot;>
    <?php require('post.php'); ?>
    <?php comments_template(); // Get wp-comments.php template ?>
    </div>
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <p align=&quot;center&quot;><?php posts_nav_link() ?></p>
    <!--- middle (main content) column content end -->

    post.php contains:

    <p class=&quot;post-date&quot;><?php the_time('D j M Y'); ?></p>
    <div class=&quot;post-info&quot;><h2 class=&quot;post-title&quot;><a href=&quot;<?php the_permalink() ?>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link: <?php the_title(); ?>&quot;><?php the_title(); ?></a></h2>
    Posted by <?php the_author(); ?> under <?php the_category(' , '); ?><?php edit_post_link('(edit this)'); ?><br/><?php comments_popup_link('No Comments', '1 Comment', '[%] Comments'); ?>&nbsp;</div>
    <div class="post-content">
    <?php the_content(); ?>
    <div class="post-info">
    <?php wp_link_pages(); ?>
    </div>
    <!--
    <?php trackback_rdf(); ?>
    -->
    <div class="post-footer">&nbsp;</div>
    </div>

    Beel

    (@beel)

    Does it work if you drop in the single.php from the default theme? I see that wp.php?p=611 will show the full post. Good luck tracking down the error, nothing jumps out at me in what you posted.

    Thread Starter wstewart1

    (@wstewart1)

    Thank you both for your help. I have discovered if I remove:

    <?php query_posts('cat=-18&showposts=1') ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

    and

    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.

    <?php endif; ?>

    It actually shows something! But, it shows the entry “Democrat food sales tax ‘solution’ creates trouble” regardless of the page you are on. Any ideas?

    Update: I added a new entry and discovered that it is showing the content of the third entry in the single post page regardless of the page I am on.

    moshu

    (@moshu)

    It works well, when you clcik the posts’ title in the “normal” display of the posts – not the one at the top.
    I assume you are using some kind of query_posts thing to display the lead post at the top, and I also assume you don’t want it to be displayed once again below.
    Try to follow this thread and the solution that was offered there:
    https://www.ads-software.com/support/topic/28203#post-193667

    Thread Starter wstewart1

    (@wstewart1)

    Thanks Moshu for taking the time to help. While this will help the index page, my problem is single.php does not show the correct content. While the <title> tag is correct, it does not show the right entry in the post. As far as I can tell, it is always offset by 3 — which is really weird.

    moshu

    (@moshu)

    That’s why I posted the above link. I assume your Loop and/or the query_posts combination is wrong.

    Beel

    (@beel)

    That is not what I see. It appears you have queried the database to select a particular post as moshu stated and need to do a second separate query.

    Edit: As moshu said twice ??

    Let’s Go… Mountaineers!

    Thread Starter wstewart1

    (@wstewart1)

    Thanks for your help and patience…I’m beginning to understand! ?? The problem lies in the script that is in header.php (I’ve removed it for now off the site):

    <?php query_posts('cat=-18&showposts=3') ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <a href="<?php the_permalink(); ?>"><strong>(<?php the_time('M. d'); ?>)</strong> <?php the_title(); ?></a>
    <?php endwhile; else: ?>
    Sorry, no posts matched your criteria.
    <?php endif; ?>

    Now to figure what is wrong…

    moshu

    (@moshu)

    What you seemingly want it is very easy to achieve using the Loop posted by Kafkaesqui in the thread I’ve linked above.
    Nothing in the header, no complications.
    Use a very, very simple single.php file.

    If I understand well, this is what you want:
    – to have an index/home page displaying 1 post from the “announcement” category at the top, with different style;
    – below that several “latest posts” but – presumably – without the post already shown at the top
    – and the rest of the blog should behave regularly: display category, montly archives, display single post with comments etc.
    Or did I misunderstand something?

    Thread Starter wstewart1

    (@wstewart1)

    No, you have guessed correctly. With your and Beel’s help I have solved it! Thanks so much for your assistance!

    moshu

    (@moshu)

    Good! Glad it worked.
    Hm. Looking at the site I’d say it’s “almost” done. I wouldn’t want the Under construction post to be repeated in the second loop.
    This is what I’ve asked here:
    https://www.ads-software.com/support/topic/28203#post-193684
    and thanks to the PHP gurus got an answer…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Not showing single post content’ is closed to new replies.