Simply create Wordpress as a CMS

Source: Internet
Author: User
Tags php file php code

It is easier to use WordPress as a CMS in version 2.1, with only five simple steps and no need to modify complex code.

Create a page and name it home as the start page, and set the page order (page order) to 0.
Create an empty page, name it weblog, and set the page order (page order) to 99.
On the management page, select option> reading and use the home created above as the front page and weblog as the posts page ).
Use this function wp_list_pages ('sort _ column = menu_order & title_li = ') to create a website menu.
Use a plug-in to make the page searchable (optional ).
You can use the Search Everything plug-in ).
When creating a page for your CMS, make sure that the order of the page must be between 0 and 99. In this case, the first one in the menu is home, and the last one is weblog. Of course, you can change it as needed.
Personally, he makes WordPress as CMS clear and clear, and you can expand it according to the simple steps provided by him.

However, in fact, simply following the steps mentioned in the citation may not successfully create Wordpress as a CMS. In my case, the final result is that there are two Home links and one Blog link in the navigation bar, and all these links point to the Blog page. View the header. Php file of theme and find that the navigation bar uses the following code to judge the cause of the current page:


Reference content is as follows:
<Li class = "<? Php if (is_home () or is_archive () or is_single () or is_paged () or is_search () or (function_exists ('is _ tag') and is_tag ())) {?> Current_page_item <? Php} else {?> Page_item <? Php }?> "> <A href =" <? Php echo get_settings ('Home');?> "> <? Php _ e ('Home');?> </A> </li>


In fact, if you use WordPress 2.0.1 or later, the wp_list_pages () function has added the current_page_item id function for the link. Therefore, a duplicate link is generated in the navigation menu. If the above code is used in the topic, you can replace it with wp_list_pages. If both are used, delete the former.

In addition, you need to add the address code in home. php to solve the problem that the homepage is still a Blog.

Reference content is as follows:

$ Homepage = get_option ('siteurl'). "/home /";
Global $ wp; $ wp_received_argument = false;
Foreach ($ wp-> query_vars as $ k => $ v) if ($ v) $ wp_received_argument = true;


If ($ wp_received_argument) require (TEMPLATEPATH. "/index. php ");
Else {
Wp_redirect ($ homepage );
Exit ();
}


 

 


Add the start and end tags of the php code before and after the code I reference.
Place the above code in home. php under your current topic directory. The current topic directory refers to wp-content/themes/your current topic. If your topic already has a home. php file, overwrite it after backup.

 

Now, when users and search engines access the homepage of your blog, they will be taken to the URL represented by the variable $ homepage. This URL can point to any page. In the code instance, enter http://yoursite.com/home /. You can change the address as you have done.

 

For blog readers, the blog can still be accessed through the navigation menu. However, for the Dark topic, after completing step 5, the final result is that the Blog in the navigation menu cannot be marked as the current page project. There is no green Mark to tell the reader which of the navigation menus is the current page.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.