I am attempting to add two loops to some theme on two separate pages: home and blog.
Blog is essentially a catalog from the posts. It's what most Wordpress pages default to like a webpage. To do this I visited "reading through configurations" and hang "top of the page shows" as 'static' with "top of the pageInch set to some Webpage I placed in Wordpress pages and "posts page" set to some Website.
Now however , after i add the loop towards the Webpage, it does not work, most probably because I've posts page set to another page.
So how do you obtain the loop to operate around the Webpage along with the website? Btw, the house page loop is simply publish title + date + maybe excerpts. Should i completely rework the theme or perhaps is case not really a possibility under Wordpress?
Oh and also the loop I am using is:
<?php if(have_posts()) : ?> <?php while(have_posts()) : the_post() ?>
It's possible that WordPress doesn't begin a loop for you personally since you make use of a static page. But when this static page is determined inside your theme (because you range from the PHP code to show the loop, I suppose it's), you could start a new loop there yourself. Just call
query_posts yourself, as well as your code should begin working.
You will find a minimum of three wayst to operate custom queries in WordPress.
Query_posts() can define the query string of the second loop. It is simple and incredibly present with do. This code is really a fundamental structure I replicated in the codex page for query_posts():
//The Query query_posts('posts_per_page=5'); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); .. endwhile; else: .. endif; //Reset Query wp_reset_query();
You can also use get_posts() that is similar.
<ul> <?php global $post; $myposts = get_posts('numberposts=5&offset=1&category=1'); foreach($myposts as $post) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
Both functions accept numerous arguments which are described around the query_posts function reference page. The arguments proven above are just good examples. Their email list of accessible args is lengthy.
Another method open to you would be to instantiate another demonstration of the WordPress Query object (WP's primary query method). Query_posts and obtain_posts both operate a second call towards the database after WordPress runs the default wordpress_query. If you're super worried about performance or reducing db hits, I would recommend learning the best way to communicate with wordpress_query to change the default query prior to it being run. The wordpress_query class provides numerous simple techniques that you should customize the query.
Best Of Luck!