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 follows. It almost works, except it only excludes the first page ID in the list: <?php $exclude_ids = get_field('exclude_pages'); $args = array ( 'post_type' => 'page', // custom post type 'post_parent' => $post->ID, 'orderby' => 'menu_order title', 'order' => 'ASC', …
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? $current_post_id = $post->ID; if(wp_list_pages("title_li=&child_of=2143&exclude='.$current_post_id.'")): if($title) echo $before_title . $title . $after_title; wp_list_pages("title_li=&child_of=2143&exclude='.$current_post_id.'"); endif;
I have a series of "Thank You" pages which result from different form submissions. I would like to be able to exclude these from sitemaps based on their template. Specifically, and as an easy example, excluding them from being listed on the basic 404 page which utilizes the wp_list_pages. I know how to manually exclude by ID but am looking for a better way to do this on scale and a more simplified approach--rather than having to edit code. Is …
I'm currently running a wp_query like this: <?php $the_query = new WP_Query( array( 'post_type' => 'photos', 'posts_per_page' => '2', 'post__not_in' => array(3), 'paged' => $paged ) ); ?> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php the_title(); ?> <?php endwhile; ?> I then have some pagination at the bottom as such: <?php next_posts_link(); ?> <?php previous_posts_link(); ?> Say I have 11 posts that the query would return but one of them has the id of '3'. This means that …
I'm using the 'featured' tag to show certain posts on my homepage. But under the single post it also shows the featured tag, next to my real tags. How do I hide this with code? I've looked at similar questions but those were to hide tags from a tag cloud or search, but not under a single post. Thanks in advance.
Custom post type name is "project". I need code in functions.php This is working for search: // Exclude custom post type from WP Search add_action( 'init', 'update_my_custom_type', 99 ); function update_my_custom_type() { global $wp_post_types; if ( post_type_exists( 'project' ) ) { // exclude from search results $wp_post_types['project']->exclude_from_search = true; } } I can not find a solution for /blog page.
I have a very simple query to display all my posts in a custom post type: <?php $page = get_page_by_title('Duck'); $args = array( 'post_type' => 'sessions', 'post__not_in' => array($page->ID) ); $query = new WP_Query( $args ); ?> <?php if ( $query->have_posts() ) { ?> <ul> <?php while ( $query->have_posts() ) { $query->the_post(); ?> <li> <?php the_title(); ?> <?php the_content(); ?> </li> <?php } ?> </ul> <?php } ?> <?php wp_reset_postdata(); ?> What I want to do is display all the …
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.php - will trigger a WP 404-page not found message. Both files, myfile.html and myfile.php exist in the Non_WP folder. My .htaccess file looks like this: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/(Non_WP|Non_WP/.*)$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress It …
The scenario is as follows: A multisite install with three sites: site1.com (admin) site2.com site3.com Q: How to exclude a folder located in the root directory, which should also be associated with site3.com? That is: exclude a particular directory that does not belong to WordPress so that it is accessible from: site3.com/folderToExclude/ Back in the day site3.com was a stand-alone site (now is part of the mentioned MU install), and this rule used to work: RewriteCond %{REQUEST_URI} !^/(folderToExclude/.*)$ but that's …
I have a custom loop to display posts based on a custom field. My problem is that if i have 2 posts and exclude 1 from the loop the category posts count (categories list widget with show count enable) still remains 2.
this is a follow up question to this post Exclude a category from the filed under list The solution given works for me. However, I'm curious how I can get this to work conditionally? Specifically, only on category archives? E.g. It will still say "Filed Under: A, B, X" on single post templates. But it will say "Filed Under: A, B" on archives. Working in Genesis, if that helps.
Need help with a wordpress-task I want ALL the posts from sub categories to be excluded. Example: Cake Pie Apple Pear Banana If i post a post in Banana, i don't want it to show up in Pie or Cake. I just want posts that are posted in banana to show in banana, not in the top categories. How can i do this? I found a code for it to put in functions.php but and it does the trick with …
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' => wp_list_pluck(get_the_category(), 'term_id'), 'title_li' => '', 'exclude' => 1 ]); But it still appears. How can I make sure it never appears, even if a post is tagged 'Uncategorized'?
I'm trying to exclude al posts with certain meta data from the search results but so far it's not working. Here's the code I'm using: function ZoekGeenLegeItems( $query ) { if( is_admin() || !$query->is_search() || $query->get( 'post_type' ) != 'item' ) return $query; $query->set('meta_query', array( 'relation' => 'OR', array( 'key' => 'KEY_itm_leeg' ,'value' => '0' ) )); return $query; } add_filter('pre_get_posts','ZoekGeenLegeItems'); Any ideas, anyone?
In my front-page I have 2 loops: the first one is for latest 20 posts in all categories the second one is for latest 6 posts in one specific category How can I remove from the second loop (specific category loop) those that already appear in the first loop (general loop)? I know that I have to use post__not_in => array($excludeID) in my second loop, but I can't catch all those id's in the first loop. Here is my code …
I have a custom function in my theme that creates a dynamic sitemap.xml file. For that I'm using $myVar = get_posts( array(...) ). In that array I need to exclude some pages. I want to exclude some parent page and all its children pages. I want to use only parent page slug to get an array of all the IDs of the parent and the children. The problem: the 'exclude' => in the array() accepts only an array of IDs. …
I have a custom menu on a wordpress + woocommerce site using the Walker_Nav_Menu class. When hiding posts (products) from the site those posts and category are still included in the custom menu. I would like to know how to remove either the specific product posts from this menu, for e.g. post ID = 6927 - or to remove the category (and the products therein) from this menu, for e.g. category ID = 41.The category I want to hide is …
How can I exclude one specific post from a WP_Query query? (For example, show all posts apart from a post with the ID 278) I've tried the post__not_in argument but it just removes all posts.. Any help would be great. Here is my current query <?php $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query(array( 'post_type' => 'case-study', 'paged' => $paged, )); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> Thanks
I have this code, and I tried adding in post__not_in as suggested by another post I found on this website, and it didn't break anything but didn't work either. I also tried different examples. Here's the php code I have <?php $args = array( 'posts_per_page' => '4', 'post__not_in' => array($currentID) ); $recent_posts = new WP_Query($args); while( $recent_posts->have_posts() ) : $recent_posts->the_post() ?> <li> <?php if ( has_post_thumbnail() ) : ?> <?php the_post_thumbnail( $size, $attr ); ?> <?php endif ?> </li> <?php …