• I am using query_post on a page in order to show all posts from a particular category, but using “<?php query_posts(‘cat=8’); ?>” alone doesn’t seem to use the same post template as my normal posts do. Is there anyway to make it use the correct template with regards to my posts?

Viewing 6 replies - 1 through 6 (of 6 total)
  • query_posts alone does nothing, at least not visually.

    You want to copy your “loop” to the new page and place query_post right before it.
    ex:

    <?php query_posts('cat=8'); ?>
    THE LOOP
    Thread Starter jazon

    (@jazon)

    I tried adding it but I got this error.

    Warning: require(post.php) [function.require]: failed to open stream: No such file or directory in **/wordpress/wp-content/plugins/runPHP/runPHP.php(383) : eval()'d code on line 1
    
    Fatal error: require() [function.require]: Failed opening required 'post.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/shattere/public_html/bladenforce/wordpress/wp-content/plugins/runPHP/runPHP.php(383) : eval()'d code on line 1

    What’s the whole thing look like, with the loop intact. I’m not familiar with that plugin but maybe it’s something with the loop code itself.

    Thread Starter jazon

    (@jazon)

    <div id="content">
    			<?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    			<div class="post">
    				<?php require('post.php'); ?>
    				<?php comments_template(); // Get wp-comments.php template ?>
    			</div>
    			<?php endforeach; else: ?>
    			<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    			<?php endif; ?>
    		<p align="center"><?php posts_nav_link() ?></p>
    	</div>

    try replacing the require(….) line with the_content();

    That’s a way of calling the loop I’m not really familiar with. Normally people use
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?> instead

    Thread Starter jazon

    (@jazon)

    I’m getting all sorts of weird errors now.

    Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 40961 bytes) in **/wordpress/wp-content/plugins/runPHP/runPHP.php on line 382

    I’m thinking the plugin I got to run PHP on my Pages, RunPHP, isn’t working correctly. Is there any other plugin for executing Php scripts from pages?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘query_post & category not showing post template’ is closed to new replies.