• Hi everyone,

    This is my first WP site from scratch (not using an already existing theme) and after a few troubles there is only one left. My post titles won’t appear.

    Here is the code for my blog.php:

    <?php /* Template Name: Blog*/ ?>
    <?php get_header(); ?>
    
    <div id="content">
    <?php get_sidebar(); ?>
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <div class="maincontent" id="post-<?php the_ID(); ?>">
    
    <?php the_content('Read more &raquo;'); ?>
    <?php comments_popup_link( 'No comments', '1 comment', '% comments', '', ''); ?>
    
    <span class="h_blog">
    <?php the_title(); ?>
    </span>
    
    </div>
    
    <?php endwhile; ?>
    
    <?php else : ?>
    
    <div class="maincontent">
    <h2>Page can not be found!</h2>
    <p>The article or page that you are trying to reach can not be found. It may have been deleted or moved. Please use the navigation menus or the search box to look elsewhere.</p>
    </div>
    
    <?php endif; ?>
    <div class="spacer"></div>
    </div>
    <?php get_footer(); ?>

    and here is the code for my index.php:

    <?php /* Template Name: About*/ ?>
    <?php get_header(); ?>
    
    <div id="content">
        <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
                <?php get_sidebar(); ?>
                <div class="maincontent">
                    <?php the_content('Read more &raquo;'); ?>
                    <?php comments_popup_link( 'No comments', '1 comment', '% comments', '', ''); ?>
                </div>
            <?php endwhile; ?>
    
        <?php else : ?>
            <div class="maincontent">
                <h2>Page can not be found!</h2>
                <p>The article or page that you are trying to reach can not be found. It may have been deleted or moved. Please use the navigation     menus or the search box to look elsewhere.</p>
            </div>
        <?php endif; ?>
        <div class="spacer"></div>
    </div>
    
    <div class="spacer"></div>
    
    <?php get_footer(); ?>

    Am I missing something (obviously)? I trying taking this code from the default theme, but still didn’t work:

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

    any help is much appreciated.

Viewing 5 replies - 1 through 5 (of 5 total)
  • from index.php:

    <div id="content">
        <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
                <?php get_sidebar(); ?>
                <div class="maincontent">
                    <?php the_content('Read more &raquo;'); ?>

    i assume get_sidebar() should be before the loop?
    and there is no code for the_title(), yet.

    did you mean something like this:

    <div id="content">
        <?php get_sidebar(); ?>
        <?php if (have_posts()) : ?>
            <?php while (have_posts()) : the_post(); ?>
                            <div class="maincontent">
    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
                    <?php the_content('Read more &raquo;'); ?>

    Thread Starter euroskip

    (@euroskip)

    PERFECT! thanks so much alchymyth. for anyone else that is using this, just don’t forget the close tag on the added line of code.

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

    Thread Starter euroskip

    (@euroskip)

    Hey alchymyth,

    one thing though: i had it setup so that there were no page titles, how can i get rid of those again, but keep the blog post titles, as you showed me?

    thanks,

    -A

    copy index.php and save it as page.php (if you don’t have one already). then remove the title code from page.php.

    trishalamb

    (@trishalamb)

    My Blog posts are appearing but not when you click on the category.
    Does that seem odd?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Blog Post Titles not appearing?’ is closed to new replies.