Answer the question
In order to leave comments, you need to log in
How to exclude a post in WordPress by its ID?
The post displays the "Related Pages" block. This block shows links to posts that are in the same category as the post itself. I need to exclude the link to this post so that the page doesn't link to itself.
I'm trying to exclude a post of a certain category like this:
$arg = array (
'cat' => 54, // выводить посты из этой категории
'post__not_in' => 2197, // исключить конкретный пост
'posts_per_page' => 10, // сколько постов выводить
'orderby' => rand // рандомно
);
post__not_in => 2197
Answer the question
In order to leave comments, you need to log in
Try throwing an array there
$arg = array (
'cat' => 54, // выводить посты из этой категории
'post__not_in' => array(2197), // исключить конкретный пост
'posts_per_page' => 10, // сколько постов выводить
'orderby' => rand // рандомно
);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question