Home > php教程 > PHP开发 > Simply turn WordPress into a CMS

Simply turn WordPress into a CMS

黄舟
Release: 2016-12-14 16:16:41
Original
1370 people have browsed it

Using WordPress as a CMS becomes even easier in version 2.1. It only takes 5 simple steps and does not need to modify complicated code.

Create a page and name it home as the start page, and give its page order (page order) to 0.
Create an empty page and name it weblog and give it page order (page order) of 99.
In the management interface, select option > reading, and use the home created above as the front page (start page) and weblog as the posts page (article list page).
Create website menu through this function wp_list_pages(’sort_column=menu_order&title_li=’).
Use a plugin to make the page searchable (optional).
You can choose the Search Everything plug-in (written by the translator).
When creating pages for your CMS, make sure the page order 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 according to your own needs.
Personally, I think he explained WordPress as CMS more clearly and clearly, and you can expand it according to the simple steps he provided.

However, in reality, following the steps mentioned in the quote exactly will not necessarily successfully turn Wordpress into a CMS. In my case, the end result was two Home links and one Blog link in the navigation bar, and all three links pointed to the Blog page. After checking the header.php file of the theme, I found that the navigation bar uses the following code to determine the current page:


The following is the quoted content:


  • In fact, if you are using WordPress version 2.0.1 or above, the wp_list_pages() function already has the function of adding the ID current_page_item to the link. Therefore, the coexistence of the two will produce duplicate links in the navigation menu. If the above code is used in the theme you are using, consider replacing it with wp_list_pages(). If both are used, consider deleting the former.

    In addition, regarding the problem that the homepage is still the Blog, it needs to be solved by adding the redirection code in home.php.

    The following is the quoted content:

    $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();
    }

    Please add the starting and ending tags of the PHP code before and after the code I quoted
    Place the above code in home.php in the directory of your current theme. The current theme directory refers to wp-content/themes/the theme you are currently using. If your theme already has a home.php, please overwrite it after backing it up.

    Now, when users and search engines visit 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 example this is http://yoursite.com/home/. You can change this address as you like.

    For blog readers, the blog is still accessible through the navigation menu. However, for the Dark theme, after following the 5 steps, the final result is that the Blog in the navigation menu cannot be marked as the current page item. There is no green mark to tell readers which item in the navigation menu the current page is.

    For more related articles, please pay attention to the PHP Chinese website (m.sbmmt.com)!

    Related labels:
    source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Recommendations
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template