Any wordpress wizards out there?

Soldato
Joined
1 Sep 2005
Posts
10,001
Location
Scottish Highlands
I'm currently trying to get a page to display posts from a certain category correctly.

http://www.afowler.co.uk/adventures/

This is a wordpress page with a custom loop, so it displays only posts from category 10. This works fine so far, and pagination works correctly as well. However, when I click on the title of a post to read the entire post, it simply displays the list of posts again, not the expanded post.

This is what the page template looks like;

PHP:
<?php
/**
 * @package WordPress
 * @subpackage Default_Theme
 */

/*
Template Name: PageofPosts
*/
?>

<?php get_header(); ?>

	<script type="text/javascript">
		var main_nav = "adventures";
		navigation();
	</script>

	<div id="content" class="narrowcolumn">	


<?php /* Page content */ ?>

	
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<div class="post" id="post-<?php the_ID(); ?>">		
		<div class="entry">
			<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
			<?php if ( comments_open() ) : comments_template(); endif; ?>
			<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
		</div>
	</div>
	<?php endwhile; endif; ?>

<?php /* Post list */ ?>

		<?php
		$temp = $wp_query;
		$wp_query= null;
		$wp_query = new WP_Query();
		$wp_query->query('cat=10&posts_per_page=3'.'&paged='.$paged);
		while ($wp_query->have_posts()) : $wp_query->the_post();
		?>
		

		
			<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
				
				<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
				<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

				<div class="entry">
					<?php the_attached_image(); ?>
					<?php the_content('Read the rest of this entry &raquo;'); ?>					
				</div>

				<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
			</div>

		<?php endwhile; ?>


		<div class="navigation">
			<div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
			<div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
		</div>

		<?php $wp_query = null; $wp_query = $temp;?>

	</div>

<?php get_sidebar(); ?>
<?php get_footer(); ?>

Any ideas of where I'm going wrong? I don't know PHP so am having problems tracking down the issue. :)
 
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

I work with WordPress, this is the line you need to modify, though I'm not sure why the permalink isn't working as it looks fine here!

Looking on the website it seems like you're using a custom taxonomy as well?
 
Last edited:
I work with WordPress, this is the line you need to modify, though I'm not sure why the permalink isn't working as it looks fine here!

Thanks for the reply. Yeah, I know this is the post title link, however the code is exactly the same as the one in my index.php file which works. It is something to do with it being a custom loop, using a template file for the page.
 
You could try using the other looping method (below, adapt as necessary). But I am confused as to why the links are correct, yet the page remains the same... :confused: Surely your permalink structure or htaccess is doing something there..

PHP:
<?php $posts = query_posts(array('post_type' => 'page'));
				
				if( $posts ) : ?>
				<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
				
				<a href="<?php the_permalink(); ?>" class=""><?php the_title(); ?></a>
				
				<?php endforeach; ?>
				<?php endif; ?>
				<?php wp_reset_query(); ?>
 
Last edited:
Back
Top Bottom