WordPress First page does not display the method of assigning a classified article

Source: Internet
Author: User
Keywords WordPress

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

How to achieve the WordPress home page does not display the specified category article, to achieve this step, you must first find the ID of the directory that needs to be screened, then how to view the wordpress classification ID? There are two ways to do this:

View the IDs of categories through WordPress background

First into the WordPress category directory, put the mouse on the right side of the category name or the name of the Edit button below, when the browser's status bar (bottom left) will display the URL address, similar to the following address:

  

Hold the mouse over the product center category name, and then view the browser status bar display information, in the browser status bar display information, the red line in the tag_id=1 of the number "1" is the ID value of the category.

  

When you get the category ID you want, how do you realize that the WordPress home page does not display the article under the specified category?

WordPress Home page does not display the specified category article method one:

Normally, the main page of the theme loop calls the latest article list with this code

Therefore, if you do not want to display a category on the first page of the article, just to add a sentence under this code

Change the number of in_category (' Binaphthyl ') here to the ID of the category you don't want to display.

WordPress Home page does not display the specified category article method two:

In the root directory to build a folder, such as my blog need to block it directory, then the folder is named it, the site displayed as http://seoxuexi.org/it. Then upload the same program in the folder, including the stencil.

In this way, the article you update in the IT template will not appear on the home page, the principle is very simple, because the two are not using the same program.

Disadvantages of this method: more trouble, if the template has changed, need to synchronize both sides of the change.

Both of these methods are really useful for me to experiment with myself. You might as well try. Here are a few people on the Internet to share, but I have not tried, but also to share with you:

WordPress Home page does not display the specified category article method three:

Go to the index.php blog or find it in the

if (have_posts ()) or while (Have_posts ()), add the preceding query_posts function as follows:

$paged = (Get_query_var (' paged '))? Get_query_var (' paged '): 1;

$args = Array (

Category ID that you do not want to display, separated by a half-width comma

' Category__not_in ' => Array (42),

' Paged ' => $paged

);

Query_posts ($args);

WordPress Home page does not display the specified category article method four:

Or find it in index.php

if (have_posts ()) or

while (Have_posts ()), changes the entire row found to:

if (Have_posts ()): Query_posts ($query _string. &cat=-42′); while (Have_posts ()): The_post ();

42 is the category ID that you do not want to display, separated by a half-width comma.

How to block the articles under multiple categories, simply add them multiple times in the IF (Have_posts ()), as I need to screen out the classification id22,17,25,24,23.

Related Article

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.