Questions tagged [exclude]
The exclude tag has no usage guidance.
208
questions
1
vote
2
answers
3k
views
Exclude Posts From Specific Category from Next and Previous post links
I've been searching for this a lot...but all I get is not what I need.
I simply want to show next and previous links on single.php (from all the categories, based on publish date, not just in the ...
1
vote
2
answers
983
views
Exclude some categories from the post page
I have created a page called "videos", this is set as the post page where all post should show up.
That´s fine, but I want to exclude all posts from two of the sites categories.
I tried this code, ...
0
votes
1
answer
94
views
widget exclude post by custom field
I have a widget that gets posts from different post_type's.
I want to exclude some posts that have a custom field value
e.g.
I save a form where a checkbox adds a value of 0 or 1 depending if ticked.
...
0
votes
1
answer
5k
views
Category menu that filters out empty categories
I'm trying to build a menu which can be administered from the menu editor, but gets filtered before being output.
More specifically the menu contains Woocommerce product categories, organised into a ...
4
votes
1
answer
3k
views
Exclude categories from Loop, queries, widgets, post navigation
I recently ha a use case where I needed to prevent a certain category from being displayed in the front-end. In detail I needed to exclude posts assigned to that category from
the main query (“the ...
0
votes
1
answer
1k
views
Weird string offset errors when displaying post attachments
I'm trying to create a gallery page that takes image attachments from a certain category and displays them. It works but I have a problem it seems where I'm trying to exclude certain attachment types ...
0
votes
1
answer
1k
views
Exclude category from get_the_category
I want to exclude a specific category from the loop, here's what I tried:
Original code:
// auto posts by cat
if( $bawmrp_options['auto_posts'] == 'cat' || $bawmrp_options['auto_posts'] == '...
3
votes
1
answer
461
views
Excludes posts that don't have attachments in the_content()
I'm trying to write a loop that excludes posts that don't have attachments in their content areas.
I've got 200 posts in a custom post type called "students". I need to do a query of all students ...
0
votes
1
answer
1k
views
I need to exclude from a query a category and a few custom taxonomies
I need to exclude from a query a category and a few custom taxonomies.
Is this code right? This query don't exclude any post, the one with the category, or the custom taxonomy.
What am I doing wrong?
...
1
vote
2
answers
2k
views
Get attached media only
I am using wp_query to get uploaded medias. Everything is working fine, but wp_query will return the medias with no post attached. This is not what I wanted. How can I exclude the unattached media ...
0
votes
1
answer
2k
views
Exclude categories by ID
I've searched this site and tried all kinds of ways to exclude categories 1 and 7 from this list, but nothing is working. No errors but doesn't hide the cats either.
Categories 1 and 7 are not empty, ...
0
votes
1
answer
49
views
Don't execute function on specific posts
function content_strip_img($content) {
global $post;
if ($post->ID !== 1 || $post->ID !== 2 || $post->ID !== 3 ) {
return preg_replace('/<img[^>]+./','', $content);
}
}
...
2
votes
4
answers
8k
views
How to exclude categories from recent posts, recent comments & category widgets?
I use the bellow function (thanks to @helgatheviking!) to exclude categories from the wordpress loop. It works very well - posts of selected categories are excluded from the loop on the main blog ...
-1
votes
1
answer
36
views
Excluding cateory not working on my site. how to solve this? [closed]
I am using my own wordpress theme.
I am trying to exclude some categories on my author.php
I am using the following code for that purpose.
$paged = (get_query_var('paged')) ? get_query_var('paged')...
17
votes
2
answers
4k
views
How do I exclude plugins from getting automatically updated?
There is an opt-in filter that allows all plugins on my site to receive automatic updates:
add_filter( 'auto_update_plugin', '__return_true' );
I like this feature, but I don't want all my plugins ...
1
vote
1
answer
261
views
exclude post from displaying in loop if it is in a category, but not in many categories
I am searching how to exclude posts from displaying in a loop if them are in a category x, but not in many categories...
The Problem: if I do exclude posts i.e. out of category 5, all posts are listed ...
0
votes
1
answer
368
views
How to display elements of different post types?
What happens is:
I have a custom post type called "placas" and have an associated custom taxonomy called "firmas" and this taxonomy is the terms "LG", "AOC", "Panavox".
I want to show a certain ...
0
votes
1
answer
323
views
specific post is not excluded from the loop
I have registered a CPT and created archive-myCPT.php, here I want to exclude a specific post from the main loop.
This is my code:
<?php
$query = new WP_Query( array(
'post_type' => '...
1
vote
0
answers
1k
views
Exclude custom taxonomy term posts from custom post loop
I have a custom post type set up called projects with a custom taxonomy called categories that has a number of terms. For one of them called archive I would like to remove its associated posts from ...
0
votes
2
answers
2k
views
remove term from custom taxonomy list
I have the terms of a custom taxonomy presented in a list like this:
<?php $taxonomy = 'categories'; $tax_terms = get_terms($taxonomy); ?>
<ul>
<?php foreach ($...
0
votes
1
answer
342
views
link to a random custom post while excluding current post
I am using the below code to create a link from a custom post to another random custom post.
<?php $args=array('post_type'=>'projects', 'orderby'=>'rand', 'posts_per_page'=>'1'); $...
0
votes
2
answers
210
views
Exclude recently updated post from custom WP_Query using multiple loops
I want to do something like this but can't manage to figure it out.
[Click][1]
I am using this custom WP_Query to display upcoming events on my homepage.
$events_args = array(
'...
0
votes
0
answers
930
views
Exclude Categories from wp_list_categories()
in before: I already searched for this answer her but couldn't find a thing that worked for me.
I have a Lot of Categories and Child Categories. I use them to give a Location, Country, Type of ...
1
vote
2
answers
426
views
Exclude the first 'n' number of posts of a tag from home page?
Use case (example): Using a separate, custom query my website's home page shows 5 featured posts, tagged 'Highlights (highlights)', followed by the latest posts, from the main query.
I don't want the ...
1
vote
1
answer
84
views
How to query posts to include specific pages of one post type, and all pages of another post type?
I'm having trouble figuring out how to query all posts from the post type "events", as well as including four specific pages in the loop.
If I use the "include" parameter, it only returns the ...
0
votes
1
answer
2k
views
WooCommerce Hiding A Certain Category From Being Displayed On Single Product
If I go to
wp-content/themes/theme-name/woocommerce/single-product/meta.php
then I see this code:-
<?php
/**
* Single Product Meta
*
* @author WooThemes
* @package WooCommerce/...
1
vote
2
answers
3k
views
How do I exclude posts by custom field value?
I need to exclude posts that have a custom field 'city' value of 'Melbourne'.
After much searching I think the solution might consist of 2 parts.
In functions.php :
A function to get the post IDs ...
0
votes
1
answer
763
views
Terms from current post custom taxonomy -- excluding parent and only from a single parent term
The title sounds complex but this is quite simple. Hopefully the code for it is too. I have this custom taxonomy we'll call "Filters".
ParentTerm A
ChildTerm 1A
ChildTerm 2A
Parent Term B
Child ...
0
votes
1
answer
455
views
Exclude taxonomy term from all loops, but having it on widget
I have excluded a custom post type taxonomy term from all posts like this:
add_action( 'pre_get_posts', 'exclude_category_posts' );
function exclude_category_posts( $the_query ) {
$taxquery = ...
2
votes
1
answer
10k
views
exclude custom post type by meta key in wp_query
I'm trying to display a custom post type (properties) and exclude posts that have a certain meta value (sold). Is there a way that I can do this? I have this for my code so far:
...
1
vote
1
answer
2k
views
Exclude featured image from attachment loop
For my jigoshop theme I'm able to retrieve the images attached to my product post. However it pulls all images from both the featured image and my metabox images. What I'm trying to do is make it so ...
-1
votes
1
answer
462
views
exclude page element from specific pages
I'm using a specific navigation menu that should be present on all but two pages. How can I exclude <div class="portfolio-nav"> from the specified pages(About & Contact)?
<?php ...
0
votes
1
answer
2k
views
List post wit the same category but exclude parent
I have the followind code:
<?php global $post;
$cat_ID=array();
$categories = get_the_category(); //get all categories for this post
foreach($categories as ...
0
votes
3
answers
515
views
2 wordpress loops showing 1 post from same post type - how to avoid showing the same post?
I got to two loops in my template files. Both querying the same thing essentially.
This loop in my header:
$testimonial_head = new WP_Query(array(
'posts_per_page' => 1,
'post_type' =&...
0
votes
1
answer
2k
views
Exclude posts with specific meta_value while sorting by a separate meta_value
I am trying to exclude posts with a specific meta_value with a specific meta_key while also sorting the posts by a meta_value with a different meta_key.
This is my current code for the WP_Query class:...
0
votes
1
answer
1k
views
How to exclude Sticky from Recent Post?
Im sorry about my english.
I using below code to display recent post in my footer. The problem is, my recent post show sticky post. How to hide or remove sticky post from recent post??
<div class=...
0
votes
1
answer
563
views
Exclude all sticky posts front page twenty twelve
I am attempting to exclude all sticky posts from my front page in twenty twelve theme. I have attempted the following. I am making all changes to the child theme.
To remove the following code from ...
0
votes
1
answer
1k
views
Exclude a 'portfolio' custom category?
I have a custom post type called 'portcat' and I want to exclude one portcat category ('weather' - ID='5') from the page. I've tried 'category__not_in' => array( 5 ) but apparently this doesn't work ...
1
vote
2
answers
2k
views
pre_get_posts : 'post__not_in' doesn't work with global variable
I'm trying to set a post__not_in which use a global $popular variable, defined in the index.php.
-index.php-
$popular[] = 1 //post id=1
$popular[] = 2 //post id=2
$popular[] = 3 //post id=3
-...
1
vote
1
answer
4k
views
How do I exclude the current post from listing in recent posts
I list my two most recent posts from a widget on the sidebar. When I'm viewing one of these posts from single.php, I want that post to be excluded from the list and instead show the next post in order....
0
votes
1
answer
814
views
Paginate wp_query while utilizing post__not_in
I'm currently running a wp_query like this:
<?php
$the_query = new WP_Query( array(
'post_type' => 'photos',
'posts_per_page' => '2',
...
0
votes
1
answer
3k
views
Display 1 category only with get_the_category (by ID or slug)
After hours of unfruitful Googling, I am asking for your help on this issue.
My objective is to display only 1 category with get_the_category if the category ID matches the ID or slug set in the ...
0
votes
3
answers
2k
views
using pre_get_posts to exclude
I am trying to use pre_get_posts to exclude categories from posting to the homepage. If I do it like so it works just fine
$query->set( 'cat', '-13,-7,-19,-12,-24,-21,-14');
that is hard coded ...
-1
votes
1
answer
6k
views
Get first category only and excluding one
How can I get the first category (linked to the category archive page) of a post excluding the category called 'featured'? I found various solutions but I can't combine them properly.
Thanks
UPDATE:
...
0
votes
2
answers
5k
views
How do I remove a category from a wordpress loop>
I have a question. I need to have, in my archive.php file, a exclusion of a specific category. given what I have now, how would I make that happen?
Here is the code:
<?php
...
0
votes
1
answer
121
views
Homepage custom recent news
Is there anyway of telling wordpress, by some plugin or whatever, not to show Recent news from Category X, on my home page?
Or I may do it only by modifying the home.php code?
0
votes
1
answer
979
views
Using WP_Query and Query_post for the loop?
I am using the code below to call post from a certain Taxonomy term. My intentions are to mix that into the normal loop.
I'm am not trying to create two different loops, but one loop that displays ...
1
vote
2
answers
570
views
Query Posts Exclude Entire Category
I am using the standard wordpress loop that looks like:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?...
0
votes
1
answer
210
views
Exclude Authors based off date of last post
I have several writers that range from frequent to one-time writers for my blog. On my Author page, I would like to separate out writers that have not posted an article in 6 months. It would be nice ...
2
votes
1
answer
1k
views
Exclude post_type from admin comments_list
I'm trying not to show comments from a certain custom post type int the comments list on the admin interface.
I went to the "wp-admin/includes/class-wp-comments-list-table.php" and tried to play with ...