开发者

Displaying static information in a Wordpress blog

I would like to create a front page for a Wordpress blog that contains static information and blog posts:

[Static Information 1]
[Static Information 2]
[Static Information 3]
[Excerpt from latest Blog post from Category 1]
[Excerpt from latest Blog post from Category 2]

The static sections will contain text, links and images and should be modifiable by administrators using Wordpress' WYSIWYG editor (so not a Text Widget). A different style will be applied to the static sections, so I don't want them turning 开发者_运维问答up in "the loop" with the blog posts.

What is the best way to achieve this?

Should I create a separate page for each static section. If so, how would I embed the page onto the front page and prevent it from appearing in the menu?

Would widgets be a better solution?


You can make a custom template in your theme to use for the front page to start with, or use the existing index.php. You can make new pages in wordpress to manage the information you're keeping static sirectly in the page manager. Collect each page's ID number. Those are the pages you want for your new theme file. Use the get_posts() function to retrieve those for your theme template:

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

It has an argument called "include" where you can pass the id number directly:

$static = get_posts('include=10,11,12,13');
if($static){
    foreach($static as $post){
        //output some html here
    }
}

Then, look for wherever you use the wp_list_pages() function in your theme. There is an argument for that function called "exclude" where you can pass in post IDs in the same manner you passed them in in get_posts().

wp_list_pages('exclude=10,11,12,13');

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜