I have a portion of a page template that is conditional upon the following elseif
<?php elseif( isset( $wp_query->query_vars['details'] ) && $wp_query->query_vars['details'] == 'child':
Is there a way to exclude a queries from a particular page slug? I would like to exclude queries coming from a page called services-we-provide
.
I tried the following with no luck:
&& !$wp_query->query_vars('pagename=services-we-provide')
EDIT:
I guess another thing I could do is add a elseif
before the one above that looks to see if you’re coming from the services-we-provide page…is that possible, if so, how would I go about that?
EDIT 2:
A little more research and I foudn that this is usually done with a referrer. I found this javascript, however I’m unclear how / where to implement and how to reference in the elseif
statement: https://stackoverflow.com/a/2163851/745514
Any help would be greatly appreciated.
I ended using the
wp-get-referer
function in a conditional. Here’s the resulting code:WP_Query does not exclude post objects based on title (using the post__not_in => array() parameter), rather based on its ID. So you would need to do another WP_Query, get_posts, or direct query on the database to obtain the post ID from title and use it on the WP_Query.