WordPress.org

Support

Support » Themes and Templates » Blog posts not linking to single.php

Blog posts not linking to single.php

  • Hello,

    I am currently working on creating a custom theme but having an issue with my blog page. As you can see on the blog page I have a few test posts but they are not linking out to the single.php. I am wondering about what I need to do to make this happen so I can then style a specific single.php.

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Moderator Jose Castaneda

    @jcastaneda

    THEME COFFEE MONKEY

    It appears that you are linking to the post. What does your index.php/home.php loop look like?

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<h1><?php the_title(); ?></h1>
    				<h4>Posted on <?php the_time('F jS, Y') ?></h4>
    				<p><?php the_content(__('(more...)')); ?></p>
    				<hr>
    
    				<?php endwhile; else: ?>
    					<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>
    Moderator Jose Castaneda

    @jcastaneda

    THEME COFFEE MONKEY

    try:

    <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>

    instead and that will link to the post. That is the reason it’s not linking to the single.php

    If i delete the old code on the index.php and the new one in its place nothing seems to happen? All blog posts are now completely removed.

    Moderator Jose Castaneda

    @jcastaneda

    THEME COFFEE MONKEY

    The new index.php should look like:

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    
    				<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
    
    				<h4>Posted on <?php the_time('F jS, Y') ?></h4>
    				<p><?php the_content(__('(more...)')); ?></p>
    				<hr>
    
    				<?php endwhile; else: ?>
    					<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>

    Thanks this worked great for links that were plain text. However if a post has an image included in it, once you click the image it just shows the image on a blank white page instead of linking to the post. Any ideas?

    Moderator Jose Castaneda

    @jcastaneda

    THEME COFFEE MONKEY

    I want to say that can be modified through the media panel. There is an option for whether to link to the attachment page or not. Yeah, it’s been that long since I’ve used media upload. 🙁

    Thank you.

    Resolved

    Moderator Jose Castaneda

    @jcastaneda

    THEME COFFEE MONKEY

    You are very welcome. 🙂

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Blog posts not linking to single.php’ is closed to new replies.
Skip to toolbar