how to post to wordpress page

If you are a wordpress newbie,i believe that you are in trouble about how to post to wordpress page,the same as most people.As we know,we can’t choose any page when we post,but we can assign posts from a specific category depending on a category id to a page,and we can choose a category when we post,after doing so,we can post to a page by choosing the category to retrieve the posts in that category.Follow these steps below we can post to wordpress page successfully.

1.creating your own page templates

The files defining each Page Template are found in your Themes directory. To create a new Custom Page Template for a Page you must create a file. Let’s call our first Page Template for our Page PageOfPosts.php. At the top of the PageOfPosts.php file, put the following:

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

The above code defines this PageOfPosts.php file as the “PageOfPosts” Template. Naturally, “PageOfPosts” may be replaced with most any text to change the name of the Page Template. This Template Name will appear in the Theme Editor as the link to edit this file.

In addition,you have a quick way to do that:open the index.php file which is in your default theme folder and copy all contents,then create a new file,paste the contents to new file and save,name PageOfPosts.php.

2.make some changes of PageOfPosts.php

Add a piece of code below after  <?php if (have_posts()) : ?>

<?php

$limit=get_option(‘posts_per_page’);

$paged=(get_query_var(‘paged’))?get_query_var(‘paged’):1;

query_posts(‘cat=3,4&showposts=’ .$limit .’&paged=’ .$paged);

$wp_query->is_archive=true;

$wp_query->is_home=false;?>

The above code cat=3,4 means to display the posts of the category ID is 3 and 4.

This is designed to work with laokboke Default theme, but should work with other themes with a little modification.

3.create a page of posts

Create a page,assign PageofPosts as the Template when creating the action Page.

4.post to wordpress page

Choose the specific category when we post,the category id must corresponds to the category which define in PageofPosts.php.

 

how to post to wordpress page》有1个想法

  1. Pingback: how to post to wordpress page « laokboke

评论已关闭。