Thread Starter
Harvey
(@harvey)
Thanks for all the info! I’m always surprised by WP’s flexibility.
At first glance, I think that it will be easist for me to include THE LOOP on a new PAGE in my site, and config that LOOP to only show posts by a certain author, or category.
Let me see if I can figure out how this works…
Thread Starter
Harvey
(@harvey)
I’m getting stuck on one simple thing.
How do I include THE LOOP, in some other page?
I tried putting my LOOP code into a PAGE that I created, however, the page just displays the code, doesn’t read it as code as I wrongly guessed it would.
Then, I tried taking my index.php, and saving it as somethingelse.php and putting it back into my /wp/ directory and tried to link to it.
For some reason I couldn’t get a link to this page to work either, always get page not found.
But if I can get the code into another php file, I should be able to edit this “other” loop to display only the posts I want filtered by category or author or whatever, correct?
Any help on this appreciated!
To put code in a Page via the Page Content field, and expect it to work, you’ll need to use a plugin like:
PHPExec Plugin
http://priyadi.net/archives/2005/03/02/wordpress-php-exec-plugin/
or, RunPHP Plugin
http://www.nosq.com/2004/10/runphp-wordpress-plugin/
The Templates and Template Hierarchy articles, and the Category:Templates will help you decide if you want to put code in Pages or modify your Themes‘ template files.
Also How do I create an archives page?
Thread Starter
Harvey
(@harvey)
Brain explosion!
Bear with me here. I’m hanging on the edge.
Conceptually what I think I need.
– A new page which shows posts
– This new page -only- shows posts from a certain category
– This page must include the LOOP
– This page’s LOOP is configured differently than my index.php loop which is used for my main blog site.
Technically to do this…
– Doesn’t need to be a PAGE.
– Create a new directory inside of my /wp/
– Inside this directory, include index.php, but also a category-1.php
– This category-1.php will show the LOOP for all posts of category 1 and have priority because of hierarchy rules.
– Also, in category-1.php, must make it only display certain category posts (cagetory 1) **not sure how to do this.
– link from the main page, over to that category-1.php? or is it over to that new PAGE?
Or…
Seems like, I can make the category template. And when they click the CATEGORY=1 stuff on my main page, they will see only those posts, displayed with my category-1.php template.
However my problem here is that I don’t want my category 1 stuff to appear in my regular index.php stuff.
Need to make index.php exclude everything from a certain category
Which I have been pointed to…
However, using the EXCLUDE category technique, I tried it, and it works, however, when it excludes the post, it leaves a big -blank- area where the post should be. Is there anyway I can get it to exclude all posts from that category, however instead of leaving a blank, to just fill in with whatever post should be coming next? I guess i could get this blank in my case because of the funky tables I have going on which allow me to post horizontally instead of vertically…
So close! Yet so far.
Thread Starter
Harvey
(@harvey)
<!--HORIZONTAL -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- The following tests if the current post is in category 3. -->
<!-- If it is not, the code within The Loop is executed as normal. -->
<!-- If it is, nothing is done until the next post is processed. -->
<?php if ( !(in_category('21')) ) { ?>
<!--HORIZONTAL GET COLUMNS SAME HERE -->
<td VALIGN=TOP WIDTH=25% bgcolor="white">
<!--HORIZONTAL-->
<div class="entry">
<!-- <h4 class="entrydate"><?php the_date() ?></h2> -->
<!-- <h4 class="entrytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3> -->
<h4 class="entrytitle2" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
<div class="entrybody">
<?php the_content(__('(more...)')); ?>
<p class="comments_link">
<img src="<?php bloginfo('stylesheet_directory'); ?>/images/file.gif" title="file" alt="*" />
<?php _e("By"); ?> <?php the_author();?> <?php _e("at");?> <?php the_time() ?> <?php _e(": ");?> <?php the_category(',');?><br/>
<?php
$comments_img_link = '<img src="' . get_stylesheet_directory_uri() . '/images/comments.gif" title="comments" alt="*" />';
comments_popup_link('No Comments', $comments_img_link . ' 1 Comment', $comments_img_link . ' % Comments');
?>
</p>
</div>
<!-- <?php trackback_rdf(); ?> -->
</div>
<?php comments_template(); // Get wp-comments.php template ?>
<!--HORIZONTAL-->
</td>
<!--HORIZONTAL-->
<?php } ?> <!-- Close the exclude 21 if statement. -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<!--HORIZONTAL -->
</tr>
</table>
<!--HORIZONTAL -->
<?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>
</div>
</div> <!-- The main content column ends -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>