WordPress.org

Ready to get started?Download WordPress

Forums

query_post & category not showing post template (7 posts)

  1. Jazon
    Member
    Posted 7 years ago #

    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?

  2. MarkMichon
    Member
    Posted 7 years ago #

    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
  3. Jazon
    Member
    Posted 7 years ago #

    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
  4. MarkMichon
    Member
    Posted 7 years ago #

    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.

  5. Jazon
    Member
    Posted 7 years ago #

    <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>
  6. MarkMichon
    Member
    Posted 7 years ago #

    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

  7. Jazon
    Member
    Posted 7 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic