I am a new comer to WordPress. I've my website (Content management systems) divided to many pages inside a tree hierarchy. I am attempting to view posts inside a specific category inside a subpage. But for whatever reason event the easy "the loop":
<?php if (have_posts()) : while (have_posts()) : the_post(); the_content(); endwhile; endif; ?>
Shows ONLY (!!) the page content with no posts whatsoever ... How do i do this?
You'll need a call to question_posts() first, before your loop starts.
You can observe the entire documentation here:
I am unsure of that you would like your page content method call within the while loop, because it will likely be displayed again and again again. I would recommend moving it to outdoors from the loop.
Incidentally, to obtain posts from the particular category, use:
<?php query_posts('category=category-name'); ?>
Where category-title may be the title from the category itself. It may be the category's slug title rather, but I'd try that first.
This can be used within the loop to develop a (or a listing) permalink of the latest publish in a single category. Change mycategoryname for your own category, and showposts to -1 to exhibit all, or any other number to exhibit time of posts.
<?php $my_query = new WP_Query('category_name=mycategoryname&showposts=1'); ?><?php while ($my_query->have_posts()) : $my_query->the_post(); ?><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a><?php endwhile; ?>
The fundamental concept of
WP_QUERY reaches Wordpress
out of the box The Loop, with examples