开发者

Wordpress - how to show just posts on main index

开发者 https://www.devze.com 2022-12-22 00:18 出处:网络
I h开发者_开发百科ave a Wordpress theme that I\'ve been making \'my own\' visually and can\'t seem to get the main content section to display regular posts only - instead of the boxes.

I h开发者_开发百科ave a Wordpress theme that I've been making 'my own' visually and can't seem to get the main content section to display regular posts only - instead of the boxes.

Does anyone know how I can change this without messing it up completely? I've tried stripping everything away and replacing with the 'display all posts loop' thing, but no go. I've tried adding a new page and setting that to show posts and such, but that didn't work either ... all it did was show the latest post.

Any ideas?

Thanks, Jennifer


It depends on what theme you are editing to make your own. If you were editing the default theme one way to do it would be to open index.php, define the template name with something like:

<?php
/*
Template Name: home
*/
?>

and then save it as home.php. In your admin Reading settings set that as your home page.

I am not sure what you mean by "boxes" but I assume you are not interested in the sidebar? In this file there is one main loop running and it is set to retrieve only the latest post and a sidebar. It pulls in the title of that post : the_title(); the content : the_content(); and the sidebar get_sidebar();. What do you mean by "regular posts"? If you wanted the home page to pull a selection of latest posts you would create your own loop using WP_Query.. something like :

<?php $the_query = new WP_Query('cat=3&showposts=5');
while ($the_query->have_posts()) : $the_query->the_post();?>

Where you are interested in defining the category id (3) and the number of posts to show (5). You can read more on creating these kind of loops here

http://codex.wordpress.org/Template_Tags/query_posts

Good luck :)

0

精彩评论

暂无评论...
验证码 换一张
取 消