Forums

[resolved] Permalinks to single blog posts are not working (6 posts)

  1. orbital2000
    Member
    Posted 2 years ago #

    I'm in the midst of working up a custom WP theme in 2.9.1

    http://www.manhattanmoviemag.com

    On my category pages, the post title links are broken, meaning they no longer link to the appropriate single post pages.

    Here's the code I'm using - standard fair:

    <h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>

    What am I doing wrong? Thanks:)

  2. steyr_commando
    Member
    Posted 2 years ago #

    Problem is on your single.php file, check your unnecessary endif condition, delete or fix it and try again.

  3. orbital2000
    Member
    Posted 2 years ago #

    I should note that when clicking on any of the post titles on a blog archive page, this error is generated:

    Parse error: syntax error, unexpected T_ENDIF in /home2/manhatu7/public_html/wp-content/themes/manmoviemag/single.php on line 95

  4. orbital2000
    Member
    Posted 2 years ago #

    Here's the coding for my single.php loop. There are two endifs at the end, but I'm not sure which one needs to go. Seems to generate the same error no matter which one I remove, so maybe it's my structure?

    <div id="single_wrap">
    
    	   <?php while ( have_posts() ) : the_post(); ?> 
    
    		<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
    			<h2><?php the_title(); ?></h2>
                <div class="stamp_single"><?php the_time('F jS, Y') ?><!-- by <?php the_author() ?> --> | <?php comments_popup_link(
    	'No Comments »', '1 Comment »', '% Comments »'); ?></div>
    			<p><?php the_content('<p>Read the rest of this entry &raquo;</p>'); ?></p>
    			<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    			<?php the_tags( '<p>Tags: ', ', ', '</p>'); ?>
    
    						<div class="nav"><?php
    $prev_post = get_previous_post();
    if($prev_post) {
       $prev_title = strip_tags(str_replace('"', '', $prev_post->post_title));
       echo "\t" . '<a rel="prev" href="' . get_permalink($prev_post->ID) . '" title="' . $prev_title. '" class=" ">&laquo; Older posts</a>' . "\n";
                    }
    
    $next_post = get_next_post();
    if($next_post) {
       $next_title = strip_tags(str_replace('"', '', $next_post->post_title));
       echo "\t" . '<a rel="next" href="' . get_permalink($next_post->ID) . '" title="' . $next_title. '" class=" ">Newer posts &raquo;</a>' . "\n";
                    }
    ?></div>
    		</div>
    
            	<div style="border-bottom:1px dotted #C0C0C0; margin-bottom:10px; margin-left:14px; margin-right:14px; padding:0px
                    0px 10px 0px; clear:both;"></div>
    
    	<?php comments_template(); ?>
    
    	  <?php endif; ?>
    
      <?php else : ?>
    
    		<p>Sorry, no posts matched your criteria.</p>
    
    <?php endif; ?>
    
    </div>
  5. orbital2000
    Member
    Posted 2 years ago #

    The following should work (works on other themes I've done), BUT in this case it didn't fix my problem. Now I'm getting an unexpected 'else' error.

    <?php comments_template(); ?>

    <?php endwhile; else: ?>

    <p>Sorry, no posts matched your criteria.</p>

    <?php endif; ?>
    </div>

  6. orbital2000
    Member
    Posted 2 years ago #

    RESOLVED

    The coding needed to be tweaked to work with php5.

    I removed <?php endwhile; else: ?> and replaced <?php endif; ?> with <?php endwhile; ?>. That did the trick.

    If anyone can offer an explanation as to why php5 requires the said change, it would be much appreciated. I used trial and error but have no clue what I did right:)

Topic Closed

This topic has been closed to new replies.

About this Topic