Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [exclude]

The tag has no usage guidance.

0
votes
0answers
10 views

Exclude product content from woocommerce search

I want to exclude the product content from woocommerce search. I tried the following code in my theme functions.php but it not works: if( ! is_admin() ) { function wpb_search_filter( $query ) { ...
0
votes
1answer
23 views

Create a list of pages excluding children of selected page

I am looking to find a way to create a list of the IDs of children pages from a selected page. My goal is to use the list of IDs so that I can exclude them from the following function: wp_list_pages(...
0
votes
1answer
16 views

Exclude category and post from loop in custom category.php

So I created a custom category.php where I have the following loop: <div id="category__product-grid" class="row"> <?php // The Loop while ( have_posts() ) : the_post(); ?> <div class=...
0
votes
1answer
14 views

How can I exclude a particular category from my Wordpress Page 1 and Page 2?

I have 2 pages in the Wordpress site. All 2 pages are showing posts. I need to restrict few categories in First Page and other few categories from Second Page. <?php function excludeCat($...
0
votes
0answers
29 views

Exclude taxonomy term in archives, but make it readable on its own

Background: Making an event site that automatically hides expired events. Using WP-Cron and some tinkering, I've made it so my CPT "event" automaticly has an "Active" term in the taxonomy "Status", ...
0
votes
1answer
78 views

Exclude first image from a Woocommerce image gallery

I would like to exclude the first image from the image gallery (this is not the featured image of the product) of a single product page in Woocommerce. I'm not an expert on PHP but, could an ...
0
votes
1answer
28 views

Multiple arrays in post__not_in parameter

Does the post__not_in parameter can have multiple arrays for excluding, for example, sticky posts and also the IDs of some other posts? Something like: 'post__not_in' => array( get_option( '...
0
votes
1answer
58 views

Excluding category from post navigation in Wordpress?

I'm looking to exclude a category from the post navigation. Originally, I looked up manipulating <?php the_post_navigation(); ?> to exclude categories, but a few posts I read (like this) pointed ...
0
votes
0answers
45 views

get_next_post term exclusion not working as expected

I have posts in a custom post type with a custom taxonomy. I have 5 total posts, all of which are in term A. 2 of the 5 are in term B. I want to exclude term A from the next and previous post links. ...
1
vote
1answer
18 views

Remove ID page from wp_count

I'm try to create a pages counter excluding certain ID pages but the code don't work. I'm using this code. How can I fix it? Thanks. <?php $count_pages = wp_count_posts('page'); echo "$...
0
votes
0answers
32 views

post__in and tag__not_in conflict

I have related post section in my theme. I would like to exclude posts from a certain tag. This is my query: 'post__in' => $related_posts_ids, 'orderby' => 'post__in', '...
0
votes
1answer
39 views

Exclude Category ID in function

I have the following code appending an ad block at the end of my posts function info_after_post($content){ if (is_single()) { $content .= 'AD CODE'; } return $content; } add_filter( 'the_content', '...
0
votes
1answer
53 views

How to list all tags except the current tag in tag.php

I'm struggling to find a way to list all my tags without the current tag showing when i'm on a tag.php page. All I have is this, but it's not the current tag?
1
vote
1answer
18 views

is there a way to retrieve posts that do not have a featured image assigned?

so as the questions states, what im trying to accomplish is to fetch only the posts that do not have a featured image set. i tried looking through the docs and i noticed you can use the - symbol to ...
1
vote
1answer
95 views

Combine get_page_by_title to exclude pages from wp_list_pages

I am using get_page_by_title to exclude a few pages from wp_list_pages, my code looks like: <?php $page1 = get_page_by_title('title1'); $page2 = get_page_by_title('title2'); ...
0
votes
1answer
40 views

Multiple Taxonomy post query with exclusion

I have multiple taxonomies for a custom post type ('product') and I would like people to select from the list whether they want to include one or more of the terms and if they want to exclude one or ...
1
vote
2answers
792 views

Exclude subfolder from WP-redirect works with html but not php files

I want a certain subfolder excluded from being handled by WP with its 404 - page not found message. My problem is: example.com/Non_WP/myfile.html - shows correctly but example.com/Non_WP/myfile....
0
votes
1answer
71 views

Exclude Specific Tag On Homepage

I'd like to exclude Tag ID: 26 from my homepage. I've figured out how to do it with categories, but not with tags. function exclude_posts( $query ) { if ( $query->is_home ) { $query->set( '...
0
votes
1answer
25 views

Combine “Exclude” Query in functions.php

I was wonder if I can combine these two pieces of code together? function exclude_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( '...
0
votes
3answers
153 views

Excluding posts not working

I have tried a lot but didn't got a proper result. Someone please check my code, where I am doing mistake. I want to show other posts with same categories but not the post shows on single page also ...
0
votes
1answer
464 views

Exclude pages with certain template from wp_list_pages

Before you mark this as duplicate I have tried every method in all the other questions and non of them have worked. I am trying to exclude any page with the page template page-noindex.php from the ...
0
votes
2answers
717 views

Include posts from some categories while excluding from others

I cannot successfully filter posts from some categories and exclude at the same time from others. The code is working perfectly when used to include only posts from a given category. Categories to be ...
0
votes
1answer
3k views

Exclude category from WP_Query args not working

Everything else in these args works great. The only thing that isn't working is the exclusion of the uncategorized category. I've tried both 'cat' => '-1', where 1 is the ID of the uncategorized ...
2
votes
0answers
20 views

Individual post. Meta_key, taxonomy or post status for separation?

I have a posts with custom type - TOUR. Among ordinary Tours sometimes I need to create "personal" or "private" Tour, which will be shown only to assigned user. What the way is better to exclude this ...
0
votes
0answers
36 views

Displaying Category in sidebar post widget but not in the loop on home

I've seen many pages on how to exclude a category from the home page entirely. I am setting up a site to have a widget called News that displays the latest news items on the right but it seems like ...
1
vote
1answer
513 views

I need to create a search form that will display search results from specific category

I'm trying to create a custom search box that will show posts from specific category by my choise. Every term that will be submitted in the search box will apply the search in one category data, ...
2
votes
1answer
62 views

How to exclude shortcode from specific page IDs if it's set to global

At this moment I am using the code below, to add a shortcode for a table on all the posts and pages, but I would like to exclude few pages and any post with a specific tag. (ex. page ids 10,20 and tag ...
2
votes
1answer
70 views

Filter Posts by Excluding Categories

I am logged on as admin I am on the Posts dashboard I have Posts assigned to multiple Categories and I have posts that are assigned to only one category. I want to display posts that are assigned ...
0
votes
2answers
614 views

List child pages, exclude the current page

I'm trying to display the child pages of a parent page, this is working. But when I tried to exclude the current page in the list where the child pages displayed, it's not working. How to fix this? $...
1
vote
1answer
308 views

WP_Query Excluding pages with Order is 0

I have a custom WP_Query with the following arguments $args = array( 'post_type' => 'page', 'post_status' => 'publish', 'meta_key' => 'tile-home', 'meta_value' => 1, '...
0
votes
0answers
84 views

Exclude Posts from a Widget

I downloaded a widget that would display the most popular/most visited pages, but unfortunately the widget didn't come with an 'Exclude Posts' field, which would be really useful to me. So for the ...
0
votes
1answer
176 views

Woocommerce filter function not updating

I have a simple function to exclude a few categories from my Woocommerce shop page. This is the following code: add_filter( 'woocommerce_product_categories_widget_args', 'woo_product_cat_widget_args' ...
0
votes
1answer
333 views

Excluding pages in WP_query using ACF

I have a custom loop for showing child pages of the current page, but I'd like to allow the WP user to enter page IDs to be excluded from the loop, using Advanced Custom Fields. My current loop is as ...
0
votes
1answer
169 views

Exclude category from Tag Template

I'm trying to exclude a category from my tag template. Searching gives me nothing and kinda stuck. When I add the code below to my tag template it shows all posts... and I really would like to show ...
0
votes
1answer
80 views

How to exclude one category

This script I use to show articles from the same category in my single post, excluded the actual shown post...how can I exclude category 1 of this script so, that he further shows artikels from the ...
0
votes
0answers
31 views

How to exclude a category in the following Code?

I give out the Name of the category (in single post) with the following code: foreach((get_the_category()) as $category) { echo $category->cat_name . ' '; } If my postings ist in two ...
1
vote
0answers
67 views

Next Posts Prev Posts for Standard post format only

I am using the following functions in my single.php file to display links to Previous and Next posts: get_next_post(); get_previous_post(); I store them in 2 variables: $next_post = get_next_post();...
2
votes
4answers
990 views

wp_list_categories exclude not working

I'm try to exclude a specific category from a list of categories that a custom post has (in this case 'Uncategorized' - ID: 1). I've tried exclude: wp_list_categories([ 'include' => ...
0
votes
1answer
51 views

How can I exclude a specific ID from this line of code?

I am using this code to list pages with a specific letter at the beginning of them: $first_char = 'H'; echo '<table class="alphabet" style="border:0px;border-color:transparent;"> ...
3
votes
1answer
5k views

How to filter by category in REST API, excluding posts also in other category term?

I'm using REST API to load a several posts from other site, each post must belong to a different category. However I have one "Featured events" category, that includes posts also shown in other ...
0
votes
0answers
57 views

Exclude pages by custom field (with yes/no) storing wrong data?

I might have a problem with the following codesnippet I came up with: 1.) I have a custom field (with custom fields plugin) that says YES or NO of "hide_menu_item" 2.) This is my loop to query the ...
2
votes
1answer
96 views

Query Ignoring 'exclude' Parameter?

I'm running a query to dig up related posts based on tags. If CURRENT POST has tags A, B and C, show 3 more posts that have either A, B or C tags. I also only show posts that are 365 days old or newer....
0
votes
1answer
1k views

how to get posts ids inside pre_get_posts filter?

I'm trying to do these one: On the home (front page) i have multiple posts loops. I need posts to not repeat across these loops ( i.e if post was shown in 1-st loop it should never appear in 2-nd or 3-...
0
votes
1answer
1k views

Exclude page from loop results

I am having difficulties excluding a specific page from my main index loop in my child theme. I have the following function found in functions.php that modifies my index.php loop so that it displays ...
0
votes
1answer
2k views

Exclude current post from an array of posts?

I'm trying to exclude the current post from an array and I know that the codex says that it's not possible to combine post__in and post__not_in in the same query... But in wordpress everything (well, ...
0
votes
2answers
909 views

How to exclude a specific tag from the list of tags for the current post?

I would like show a list of tags assigned to the current post, but exclude one by tag id. I tried excluding it from the array of objects returned from wp_get_post_tags, something like this: $tags = ...
4
votes
2answers
452 views

Exclude certain category from latest updates

I am creating a website. There is a column for latest updates. This is the code that i have now. I don't really good in php coding. Would like to get guidance from someone. <?php $postslist = ...
0
votes
1answer
853 views

How to get post with slug and exclude categories

I want to do a query to get posts with a slug and category__not_in. Here's what I do: $query = array( "name" => "test", "category__not_in" => array( 15 ) ); query_posts( $query ); When ...
0
votes
1answer
2k views

Exclude latest post from WP_Query taxonomy term loop

Any help would be greatly appreciated! I have a Custom Post Type 'video', with a taxonomy 'tax-video' and I'm looping through posts in the sub-taxonomy term 't-o-t-w'. I need to exclude the latest/...
0
votes
1answer
108 views

Exclude category from DB query

I have next code: $drivers_all = $wpdb->get_results("SELECT DISTINCT meta_value FROM wp_postmeta WHERE meta_key = 'driver'") With this one I get the values of all fields “driver”. How can I ...