How to post to different page on a blog base on LNMP and wordpress
Request:
Now we have a blog base on LNMP and Wordpress, we have two page named "english" and "chinese".
I want to click on the English display categories of articles in English and Chinese page in the same way.
step1:Need to create your own page templatee, directly copy a page.php file below the theme folder in the server and add below code in the file head
<?php
/*
Template Name: Your template name
*/
get_header(); ?>
Save it.
problem0:Cant see the template on page edit after we save it.
solution:Switch to other themes and then switch back.
problem1:In the interface of the theme is only one theme, there is no other theme has been installed.
solution: Because we use lnmp, for security reasons,it closed scandir method,please open it at php.ini file. You can find how to do it by google.
Now, we can see our own templae, choose and apply it.
step2:Let's associated with the page template with the corresponding category
By click on the category in the background,can get tag_id value in the url,remember the value of different categories.
Then again open our custom template
find out
<?php if (have_post()):?>
This line, add content in front of it
<?php
$catID = 0;
if (is_page('EnglishBlog')) {
$catID=3;
} elseif (is_page('ChineseBlog')) {
$catID=2;
}//Your page name and ID in this setting
if ($catID) {
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=$catID&paged=$paged");
} ?>
then save it
Now,you can by clicking on the page to view the different categories of the post.