WordPress.org

Ready to get started?Download WordPress

Forums

Blog posts not linking to single.php (10 posts)

  1. gatessg
    Member
    Posted 1 year ago #

    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!

  2. Jose Castaneda
    Member
    Posted 1 year ago #

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

  3. gatessg
    Member
    Posted 1 year ago #

    <?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; ?>
  4. Jose Castaneda
    Member
    Posted 1 year ago #

    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

  5. gatessg
    Member
    Posted 1 year ago #

    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.

  6. Jose Castaneda
    Member
    Posted 1 year ago #

    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; ?>
  7. gatessg
    Member
    Posted 1 year ago #

    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?

  8. Jose Castaneda
    Member
    Posted 1 year ago #

    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. :(

  9. gatessg
    Member
    Posted 1 year ago #

    Thank you.

    Resolved

  10. Jose Castaneda
    Member
    Posted 1 year ago #

    You are very welcome. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.