Everything is in the heap - PR update, spam attack, how to remove a category from the main page in wp. How to remove (disable) comments in WordPress How to exclude categories from the main page of WordPress

Hello friends, today’s post will be a short summary of some events from the Internet life of the blog, and there will also be a useful hack at the end of the article.

The long-awaited PageRank update from Google

Many people already know that the other day Google updated PageRank after a very long time. for a long time, and my blog received its first one. It’s unlikely that this will give me anything, but it’s still nice)

The funny thing is, I have another site, young and almost empty - there are only 20 articles in the index. Traffic is around 20-30 people per day, no backs, no comments. In short, I didn’t promote it at all, I’m just filling it out little by little. So he received PR 2, where I still can’t understand the logic =)

Brag about who else’s PR has increased (decreased) :)

the site was subject to a spam attack

For the last week, my blog has been under a massive spam attack - 700-800 spam comments come from different IPs every day. I only had this once about a year and a half ago and it ended quickly, but now something has dragged on...

I've turned on Acismet, so don't be surprised if suddenly your comments don't appear on the site right away, this paranoid person is ready to brand everyone as heretics and burn them, throw them in spam =) The measures are temporary and after the end of the attack ( I hope it ends) I'll cut off the plugin.

I’m writing another custom review

Yes, yes, they ordered another reviewer from me, the second one in a month. It will be sharpened for search traffic at the request of the customer.

It’s nice that my blog is starting to attract attention from advertisers =) If this continues, then the price will have to be raised and the food will have to be sorted out like a princess in the dining room, so as not to overcrowd the blog with advertising. Although I think this one will only be 3 articles all the time, I don’t think that much.

A blogger I know is selling his big-bellied blog

Timur decided to sell his blog wpget.ru. Titz 30 PR 2 traffic 200 people/day on average, 300+ articles in the index, the site makes money from selling links. Now the bid on telderi is only 12 thousand, this is very cheap for such a site, in fact, if I had some free money I would buy it myself)

It’s a pity, of course, that he’s selling it, but if you’re tired of it and blogging doesn’t bring you any pleasure, then it’s not worth it, it’s really better to find something more interesting to do for yourself.

How to remove a category or post from the main page of a WordPress blog and RSS feed

The other day I needed to remove a post from the main page. I've been asked more than once how to do this. I used to use a crooked and heavy plugin, but now I've found a small and easy hack that allows you to do everything in a couple of minutes.

Actually here is the code itself:

function hidecategory($query) (
if ($query->is_feed || ($query->is_home && !(is_paged())))
($query->set("cat","-24");)
return $query; )
add_filter("pre_get_posts","hidecategory");

24 is my number, you will have to insert yours.

This code is inserted into functions.php. Its essence is as follows: let’s say you want to hide some category, to do this you will find out its ID number. You can find it out when editing a category; the ID will be written in address bar browser. For example, for my “Site News” section the ID will be 24

Greetings dear friends! Today I will tell you how to exclude posts (individual posts), categories, links, tags from the main page of your blog or website, how to exclude them from the feed and search results for the blog, from archives and categories. This can be done either separately or together, as a complex.

That is, in the end we will get a small and simple piece of code, which, at our request, will exclude those articles that for some reason we do not want to show to all blog visitors, but want, for example, to show only to a separate group of people. Such a post can be put under a password and distributed for subscription...

According to my step-by-step guide, any of you will be able to implement this function on your WordPress blog, without using any plugins, that is, this will not affect the loading speed in any way.

Well, let's begin! We need a blog on the WordPress engine, we need a little desire and the ability to copy a piece of text from one document and paste it into another document. You have it all! then let's go...

This problem can be solved in several ways:

  • By adding a small piece of code to the functions.php file (let's talk about it);
  • With the help of more complex reprogramming of the template code (I don’t write such manuals, this is not the format of my blog);
  • Using the Simply Exclude plugin (I'll talk about it at the end)

So, let's assume that you have written some post and do not want it to appear on the main page of the blog. So, we do the following:


2. And now each code in order ( how to exclude records):

Code for excluding records (posts) from the main page of the site by ID


if ($query->is_home)
($query->
return $query; )

This code option will help you remove any post from the main page of your blog, no matter what category it is in, that is, it does not exclude the entire category, but only this specific post!

Code for excluding entries (posts) from the RSS feed of a WordPress blog by ID

function exclude_post($query) (
if ($query->is_feed)
($query->set("post__not_in", array(1146, 1199));) // post id
return $query; )
add_filter("pre_get_posts","exclude_post");

But with the help of this code version I will show you how to exclude records from your blog's RSS feed. What is it for? Yes, very simply, in this simple way you can delay the publication of a new article in the feed, so it will not be sent out by the feedburner service to subscribers and will not be available for viewing by reader programs or rss aggregators. All this is only necessary if you are worried about theft of your content via RSS.

The fact is that some sites have very high indexing speeds, but for your young blog it can reach several days. Evil little men do not hesitate to rip off your bloody little article from you and post it on their own. This article will immediately be included in their index, and on your blog it will be considered plagiarism. Also, without tits10 you will not be able to protect yourself in advance from this kind of injustice.

There are also special plugins that can delay the publication of an article in the feed for a certain time! In any case, whether to use this function or not is up to you. I once needed to write a short post for a narrow circle of people, I excluded it from the main page and from the feed, then completely removed it from publication and deleted it. Basically, there was a problem and I solved it this way!

Copy the code, paste it to the very top of the functions.php file, specify the post id and you're done!

How not to display posts on archive or category pages by ID

function exclude_post($query) (
if ($query->is_archive)
($query->set("post__not_in", array(1146, 1199));) // post id
return $query; )
add_filter("pre_get_posts","exclude_post");

To remove posts from categories, you just need to change is_archive to is_category

How to exclude entries (posts) from blog search results by ID

function exclude_post($query) (
if ($query->is_search)
($query->set("post__not_in", array(1146, 1199));) // post id
return $query; )
add_filter("pre_get_posts","exclude_post");

I have not checked how this will work, for example with Yandex search or Google search. Later I’ll work on this and make a small update to the post, or write in the comments. All I know is that it will work great with the standard WordPress search engine. You all have this widget - “Blog Search”!

How to exclude a post from the main page, rss feed and search results immediately by ID

function exclude_post($query) (
if ($query->is_feed || ($query->is_home || ($query->is_search)))
($query->set("post__not_in", array(1146, 1199));) // post id
return $query; )
add_filter("pre_get_posts","exclude_post");

Well, great! Just checked everything again, each code does its job perfectly. The last version of the code excludes any post whose id you substitute, excludes it from the main page of your blog (article announcement feed), rss feed (feed) and blog search results!

The very first code removed the post from only one place, namely from the main page (article announcement feed). If you need code that will exclude your post from only any two places on your blog, it would look like this:

function exclude_post($query) (
if ($query->is_feed || ($query->is_home))
($query->set("post__not_in", array(1146, 1199));) // post id
return $query; )
add_filter("pre_get_posts","exclude_post");

If you wish, you will only need to change the following variables in the second line, those in brackets - is_feed is_home is_search is_archive is_category

If something is not clear, ask!

All this information relates to the exclusion of any specific post by its ID. But this is not all that can be excluded from the main page of the blog, from the feed and from the search results. Now we will continue to understand this!

Friends, I try my best to write in a way that is clear to everyone, so that everyone, without exception, can choose the version of the code that they need and apply it on their website. Therefore, I had to take a very long path, I’m not teaching you how to think through and write such code yourself, I’m giving it to you ready-made, just take it, paste it and use it!

3. The following cycle of code options (excluding categories):

Options for excluding categories from the main, feed and search by ID

In exactly the same way, we can exclude (remove) entire categories (headings) from the main page, from the feed and search, that is, all posts that relate to some certain category, by their ID.

How to Exclude a Category from the WordPress Blog Home Page


if ($query->is_home)
($query->
return $query; )

How to exclude a category from the RSS feed of a WordPress Blog

function exclude_cat($query) (
if ($query->is_feed)
($query->set("cat","-3, -5, -7");) // category id
return $query; )
add_filter("pre_get_posts","exclude_cat");

How to not show a category in blog article archives

function exclude_cat($query) (
if ($query->is_archive)
($query->set("cat","-3, -5, -7");) // category id
return $query; )
add_filter("pre_get_posts","exclude_cat");

How to Exclude a Category from WordPress Blog Search Results

function exclude_cat($query) (
if ($query->is_search)
($query->set("cat","-3, -5, -7");) // category id
return $query; )
add_filter("pre_get_posts","exclude_cat");

How to exclude a category from RSS feed, home page and search results

function exclude_cat($query) (
if ($query->is_feed || ($query->is_home || ($query->is_search)))
($query->set("cat","-3, -5, -7");) // category id
return $query; )
add_filter("pre_get_posts","exclude_cat");

How to exclude a category from the main page and feed of a WordPress Blog

function exclude_cat($query) (
if ($query->is_feed || ($query->is_home))
($query->set("cat","-3, -5, -7");) // category id
return $query; )
add_filter("pre_get_posts","exclude_cat");

Most often they hide separate category in order to write advertising posts in it and separate them from the general mass of content!

If you need to remove, for example, several thousand articles from the main page or somewhere else, it’s easier to exclude their categories. If these are selective posts, then you will have to work hard, or use a special plugin. Although this will not be much more convenient, you will still need to go through each article and click the checkbox.

If you hide them manually, you just need to go to the “All Posts” tab in the blog console and hover over them one by one, look at the id and paste them into the code. Several thousand ID people will of course significantly increase the code, but even this will be much simpler than the code of the entire plugin, which also uses a Database.

4. The final part of our how-to (exclusion by tag, exclusion by plugin):

How to exclude (delete) posts with a certain tag from the main, feed (RSS feed) and search results by its ID

To do this we will use the following code:

function exclude_post($query) (
if ($query->is_home) (
$tags = array("3", "7", "13"); // tag ids
$query->set("tag_not_in", $tags);)
return $query;)
add_filter("pre_get_posts","exclude_post");

This example will immediately exclude the article from everywhere:

function exclude_post($query) (
if ($query->is_feed || ($query->is_home || ($query->is_search)))
($tags = array("3", "7", "13"); // tag ids
$query->set("tag_not_in", $tags);)
return $query;)
add_filter("pre_get_posts","exclude_post");

In order to exclude only from the feed or only from the search results, in the first version of the code, in the second line, substitute the values ​​already familiar to you is_feed is_home is_search is_archive is_category

Another useful point! You can add several different code options to your functions.php file and comment out the ones you don't want to use.

Let's look at an example:

Select the required code fragment → right-click and select → “Comment block” → /*code*/ (done in the PHP Expert Editor 4.3 text editor)

Using the Notepad plus plus program as an example:

I told you how to not display individual posts and entire categories on the main blog page, feed, archives, categories and blog search results using simple code. But it’s also worth giving a solution to this problem using the simple Simply Exclude plugin.

Good afternoon friends!

If you have a problem with how to disable WordPress comments on your site, then you have come to the right place.

After reading this manual, you will be able to prohibit your visitors from leaving comments on all posts, as well as on each one individually. In addition, you can remove the comment form, which is completely unnecessary if the discussion of posts is closed.

I don't know why you need to remove comments, but for that matter, the instructions are in full before you below.

In most cases, for informational sites, I do not recommend doing this, since comments are one of those ranking factors when search engines They understand that since there is a discussion on the page, the content deserves attention.

If you have some kind of business card site, directory or catalog, then comments on such a resource are completely unnecessary, since you will receive nothing except spam.

Disable commenting on new articles

This action is the first step in completely disabling comments, since it is first necessary to prohibit leaving comments on new materials, and then on existing ones.

Everything is done very simply through the WordPress admin panel. First, go to the “Settings - Discussion” item and prohibit leaving comments on new articles.

We remove this checkbox so that there is no checkmark. Now new articles should not have a comment form. If it is, then when you try to leave a comment, it will display the message “Sorry, discussion of this post is closed.”

If the form does not disappear, it means that the template is designed this way and in the last paragraph of the article I will explain how to remove it.

Disable comments for all existing posts

First, I will describe all the steps to you, and then number them in the screenshot to make it more clear.

  1. We go to the list of all records through the item “Records - all records”;
  2. Select all entries with a check box;
  3. Select to change all records;
  4. We prohibit comments and update the settings.

The screenshot is clickable. You can watch it in full size.

Note that the screenshot shows a mass editing block where you can disable commenting. In the original version, when you just go to the list of all records, it will not be there. It appears only after the 3rd action, when we select the change option.

Before mass editing to cover all posts, you need to display them on one page so that they all stand out and the changes are applied to all posts at once. This is done using the display settings (screen settings) in the admin panel.


The button is located at the very top of the admin panel on the right side. Set your own number of entries. If you need to disable 300 records, then set this value.

The process of disabling discussions for service pages (site map, contacts, etc.) also occurs. As a rule, you should always disable comments for them, since they do not provide any meaning to the site.

Everything is done in the same way as with articles, only we go to the “Pages - all pages” item.

If you need to return commenting back, then everything is done in the same way, only select the “Allow” item.

Let's look at how to disable comments on certain articles.

Remove comments from certain posts and pages

There is an option when you need to disable discussions only in some posts. For example, you publish news on your blog about the New Year's sale of your information courses. Why comments on such notes? In such cases, comments should be removed.

You can do this:

  • through a list of all records;
  • through the post editor.

Through the list of all entries, you need to go to the properties of the article and remove the checkbox from the “Allow comments” item.

You can also do this through the post editor, and this is more convenient, since you can close the discussion immediately during the publishing process. But to do this, make sure that the discussion item is displayed in the screen settings inside the editor.


At the bottom of the text entry field there should be a block with the same name, where you can remove the checkbox and prohibit visitors from communicating on the site.


The same goes for pages.

To consolidate, a short video on the information described above.

There is one last and perhaps most difficult step left.

Removing the comment form from the site

Unfortunately, not in all templates, when you disable discussions, the comment form disappears. I still have it. If your form has not disappeared and you don’t need it at all, then now I will try to explain in detail how to remove it from the site.

Unfortunately, you can’t do without editing the template files, since the form is displayed by PHP code, which needs to be removed from the file. The problem is that it is displayed differently in each template. For some, it is displayed in a separate file, and then simply loaded from PHP code. And for some, the form code will be contained directly in the record output file.

My template displays the form as the second option, when the form code is directly in the single post and page file. IN WordPress templates, which are available on the site after installing the engine, the form is output from a separate file. In general, now I will consider these 2 options.

To start, I always recommend going to the pages (page.php) and single post (single.php) files and looking for code in them that displays the form. If there is one, then simply remove it and the problem is solved. In my template, this code is displayed in full with all fields (entering name, e-mail, website and message).

It is quite possible that you have the same template structure. Then you go to these files and look for code similar to the one in the screenshot above (clickable). The code will always be similar and there will be a large presence of the words “comment” in it.

If it exists, then find its beginning and end and delete it to hell...

If not, then it is quite possible to output a comment form from another file using a function. In the standard Twentyfourteen template, this is done this way.

The form code is in another file somewhere (eg comments.php, comments-template.php). But this code is still output to a single post and page. The Twentyfourteen template implements this as follows.


In this case, the code also has the words "Comment". You can remove it, but this is not necessary, since this code does not display the form when the discussion is disabled.

There may be a situation that in the file of a single entry (single.php) and a page (page.php) you will not find any similar code, both in the first and in the second case. Then the form is displayed along with the content. This makes things a little more complicated, as some templates may have very complex functions that render the content. In this case, I suggest going to comments.php, comments-template.php (or similar) and looking for the form there.

They may contain more than one code variant. Then you delete in parts and check for the presence of a comment form on your site. I strongly recommend that you edit the files on your computer and make them backups so that at any moment everything can be returned to its place.

This process has some difficulties for a beginner. Especially if the template is confusing. In any case, I did not disable comments on my site. Therefore, if problems arise, write your questions.

That's all, friends. Bye.

Best regards, Konstantin Khmelev!