Controlling how posts are displayed in WordPress

So, I spent awhile researching how to ONLY list posts from certain categories on the homepage.  The homepage, by default, lists the 10 most recent posts across all categories.  I want my homepage to be about web development, so I only want to show posts about industry news and site issues or personal programming experiences that I come across.

This is all new to me but I read up on the WP_Query and the loop function.  My first edit was to add the following code to the loop.php page in my theme directory:


This made it so that ONLY the posts in the News category are listed on the homepage, they were however, being listed in short mode, with a “Continue Reading” link to see the whole post.

I fixed this by switching out “the_excerpt()” comments with “the_content()” comments within the loop.php file.

Now I had one final problem, when you clicked on the category links that were NOT on the homepage, these are the archives for the category listings, they would NOT show links, images, videos, slideshows or any other html.  They were being stripped of all their html code. ???? Hmmmm.

Took awhile to figure this one out, finally came up with replacing the following line of code with the code listed right below it.

Replace this:

<?php if ( is_archive() || is_search() ) : // Display excerpts for archives and search. ?>

With this:

<?php if ( is_search() ) : // Display excerpts for search. ?>

FWIW, I’m really not finding many of my solutions on the WordPress website.  I’m finding most of it with Google searches on the web.  I’m a little disappointed that the WordPress website is not a better community for solving program applications.  Oh well, at least I am finding the help I need.

Leave a Reply