functions that return a single boolean value depending on what is currently being viewed

learn more… | top users | synonyms

1
vote
1answer
384 views

How to use is_feed() to target a category feed?

is_feed (one of the many conditional tags) can be used to determine if the current query is for a feed. But how do I use it to target all category feeds? (or tag or custom taxonomy feeds for that ...
0
votes
1answer
276 views

How to echo a different field if another field is empty?

I succeeded in getting both images and video to echo into a bootstrap carousel. However, I run into a problem when the post contains no images. If there are no images then there is no class="item ...
1
vote
1answer
466 views

Wordpress function like is_category for subcategory? is_subcategory?

Is there a function in WordPress that will check if the page you are on is a sub-category archive page? Like the way is_category checks if it's a category page?
0
votes
2answers
333 views

Excluding custom post types

I'm attempting to develop an is_blog() function which returns true if the current view is a single post, blog home, or post archive. I have successfully excluded pages and attachments. My current code ...
0
votes
1answer
97 views

Adding else if conditional statement to purchased theme

I purchased a theme that I want to change a bit. I'm familiar with writing some if/else statements but not this type and not matter what I do, I can't add an else/if without breaking the code. Below ...
1
vote
0answers
212 views

bbPress: How to set conditional for specific user -or- user role, to be displayed in user profile

I've been trying to set a conditional for specific users (e.g. http://www.mywebsite.org/forum/users/john/) to display a custom "Contributor" graphic within their user profiles. The graphic would be ...
2
votes
1answer
479 views

Conditional based on the User Role of the Current Profile the user is viewing - BuddyPress [closed]

I'm using BuddyPress and need a certain block of code to show up on user role Store Owner profiles only. I'll be putting it in member_header.php, so it's just a template file. I've been digging for a ...
2
votes
1answer
323 views

is_home() in HTML head

Is there a way to check if the current page is the home page from within the head? My style.php needs the number of posts in the slider, but only on the home page. So I count my posts like this: ...
0
votes
2answers
1k views

How to check with is_page if 404.php is loaded?

I want to check if current page match at least one of two conditions. I don't want to show js code into about page and into 404 page. For the rest of my pages i show the js code. So, I use ...
0
votes
1answer
68 views

is_mobile as shortcode

I installed the Plugin "mobble" which provides some more conditional tags. As I want to hide some content for mobile devices I tried to build a shortcode [is_mobile]. But I tried many different ways ...
2
votes
1answer
38 views

How can i know when i can execute what functions of wordpress?

I like to do a bunch of stuff only on homepage and archive pages i am working with the genesis framework (not really matters i guess) if( is_singular() ) { wp_die('functions.php'); } ...
1
vote
1answer
238 views

Checking whether template part is loaded in a page

I have a template part like this: <nav id="subpagemenu" class="sidebar"> <?php get_template_part( 'nav', 'subset' ); ?> <?php get_sidebar(); ?> </nav> Both of these ...
0
votes
1answer
39 views

Conditional Custom Image Header

I thought there was a conditional for a custom image header that could check whether an image had been added (not whether the feature was enabled, but actually being used). I wanted to use it to add a ...
1
vote
1answer
64 views

Taxonomy Tag Conditionals

I'm using jigoshop as main ecommerce plugin. Jigoshop use Taxonomies call, product_cat and product_tag. In my theme I use a default (h5bp) 404.php, so every time a tag doesn't exist I get the ...
0
votes
1answer
196 views

Conditionals: What is wrong with my if/else statements? [closed]

<?php if( $settings['logo']) : ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><img ...
0
votes
1answer
180 views

Trying to place shortcode/css/html into an IF conditional statement

With the WooCommerce plugin, I'm trying to get a different template/look to apply to the individual product page depending on what category the product is in. In other words, I want a product within ...
0
votes
1answer
117 views

Only on single post page

I am using this code to show ad below single post but only if it is in specified category. Code is giving right out put but it is also showing up on archive pages. I just want to show on single post ...
0
votes
1answer
209 views

Conditional tag to determine if the user is viewing the Add Media (after clicking Add media button)

Is there a WordPress conditional tag for checking if the user is viewing the add media popup after clicking the Add media button? If none, is there an alternative function that can be used? Thanks ...
-1
votes
1answer
81 views

Quick Conditional Tag Question if elseif [closed]

I have a meta box checkbox, you click to turn on/show the blow info basically... These conditionals dont seem to be working for some reason, the first if works, but when i add in any other else if it ...
0
votes
2answers
104 views

page 1 is not paged

I have rules that only work on paginated pages (is_paged). However, they don't work on page number one (/page/1). This one is behaving exactly like the homepage (!is_paged), but unlike pages 2,3,4 ...
1
vote
1answer
264 views

How can I hide tags on a child-category page, if that tag has not been used?

I have a section of my site where I'm using child-categories and tags to sort content. I'm have a tertiary navigation for the tags (templates/nav-tags.php): <nav class="side left"> <ul ...
-1
votes
1answer
32 views

problem with not displaying content on selected pages

My objective - Display some code on every page apart from 2 pages. Now this code works fine with only one page (if its not is_home, display code)... <?php if (!is_home()) { ?> (some ...
0
votes
1answer
89 views

Showing code only on Front Page “Posts Page”

I have some code that I would only like to be displayed on the sidebar when on the blog (the page that displays the posts). Now I am using this code... <?php if(is_page('37')) { ?> ...Show ...
-1
votes
1answer
354 views

hide block of code from showing on certain pages

Just to warn you, I am a complete PHP novice! I have one sidebar for all pages, however I would like to display certain elements on this sidebar for certain pages. I know there are a few widget ...
0
votes
1answer
226 views

Detect if request is coming from wordpress conditional statement

I don't even know if this is possible and my search terms in google are not doing any good. Since the site URL and blog URL are different I had to fix the post preview bug by giving wordpress it's ...
0
votes
1answer
104 views

Show posts containing or not custom field

I'm trying to show aditional posts in the author's page. This page must have posts containing a specific meta_key and meta_value, where the displayed author it is not really the WP post's author. ...
-2
votes
1answer
191 views

Weird html output of single_cat_title - is not inside of the html element?

I'm displaying a single "featured" post at the top of the blog index page, and category pages. I'm using this conditional to display the category name of the category page if it is a category page, ...
0
votes
2answers
537 views

Using has_tag() outside loop

I want to if the check next post has a specific tag. I tried the following code, but it is not working because has_tag() only works in the loop. I want to use it outside the loop. <?php if ( ...
0
votes
3answers
113 views

How do I add a nested conditional within an echo - to use a default image if there isn't one in the post?

I'm trying to add a conditional that will display a default image if the "image" field isn't populated... here's what I'm trying to work with: $args = array( 'posts_per_page' => 3, ...
1
vote
1answer
602 views

How can I achieve something like has_post_format( 'standard' )?

In opposite to get_post_format, the conditional has_post_format() function returns a boolean value and should be the perfect function for a conditional check like: if ( has_post_format( array( ...
0
votes
3answers
2k views

Show content if parent page has children

Using this piece of code you can show content depending if it's a child-page or not: <?php global $post; if ( is_page() && $post->post_parent ) : ?> This is a child-page. <?php ...
1
vote
1answer
200 views

Check if post has gallery images/media

Is there a Wordpress conditional that I can use to check for gallery images/media in a post? I do not want to check if the [gallery] shortcode exist in a post. Attached is a screenshot of what I ...
0
votes
1answer
106 views

Conditional for a Single Post That Belongs to a Category?

I have categories like gaming and movies on my website and when a user visits any of these categories the content in the sidebar is displayed depending on the category they are in. So gaming content ...
0
votes
2answers
252 views

Display latest post depending on Meta Box content

What I want to do is display my latest post's content on a custom template page, ONLY if a meta box is filled in with the right word. In other words, if the post has a meta box named, "FEATURED" with ...
1
vote
1answer
432 views

Using Conditional Statement in functions.php

I've got this code below in my functions.php and I'd like to add two filters with conditional statement not to effect every query_posts. Something like this if(!is_admin() && ...
0
votes
1answer
249 views

Sub-category single post styling?

*CLARIFICATION: I'm trying to style the single post view of some categories & sub categories. The suggested solution works, but only on a page of posts from the selected categories. Eg. If a post ...
1
vote
1answer
468 views

How to check if the current page is a “personal activity”-page in buddypress? [closed]

I want to modify some general text in my personal-activity page in buddypress. Does any one know any conditional tag like is_page('activity') things are there for checking this? the page can be ...
0
votes
1answer
238 views

Exclude custom function content from certain pages

I have added a small custom function to display a little author bio blurb at the bottom of each blog entry in my functions.php file inside the current theme that I am using. So far so good, it is ...
2
votes
1answer
130 views

Featured Image Size Conditional Tag?

Is it possible to check what image size has been selected for the featured image and only display that image.. For example. <?php if(has_post_thumbnail('small-image')): ?> ...
0
votes
1answer
90 views

Run a php function if a predefined page is visited

I use the CubePoints plugin that rewards users with 1000 points via the following function: if( function_exists(‘cp_alterPoints’) && is_user_logged_in() ){ ...
0
votes
1answer
299 views

Testing for a shortcode using a function. 404 page throwing PHP Notice

I'm using the following function (can't remember where I found it, but I think it was written by pippin so thanks to him) to test for a shortcode. function has_shortcode($shortcode = '') { ...
0
votes
1answer
71 views

Highlight comments made by registered users of the site

How can I highlight comments that have been made by registered users of my blog?
0
votes
1answer
109 views

Conditional Tag Based on Age of Post [duplicate]

Possible Duplicate: Add inline HTML to posts published within last 24hrs I've been searching through the codex and Google and cannot not find a conditional tag based on age of post. I'm ...
3
votes
1answer
101 views

Possible to use conditionals within add_feed() callback?

I'm using add_feed() to create some custom feeds but calls to is_singular(), is_home() etc... just don't seem to work within the callback. Is there a workaround for this? Example code: add_action( ...
1
vote
2answers
142 views

How can I link a CSS file only on single posts?

If I understand is_single() correctly, it's only supposed to return true when the current "post" (in a generic sense) is a literal post (i.e., it has a post_type of post), and that it will return ...
0
votes
1answer
856 views

conditional shortcode not working

I'm using a plugin, NextGEN gallery, to display photos. Each gallery from this plugin corresponds to a different sub-page, so I'm using conditional shortcodes to assign the right gallery to it's ...
0
votes
1answer
45 views

Targeting all pages except top level pages

I have used '0' == $post->post_parent successfully in my templates to target top level pages. However, I cannot seem to target all pages EXCEPT top level pages: <?php if ( '0' !== ...
0
votes
1answer
105 views

Conditional tag to show content in custom rss feed?

The wonderful answer here helped me create a custom RSS feed, and that's one major part done. I know that there's the is_feed conditional tag to show content only if it's a feed. But is there a ...
0
votes
1answer
67 views

nested conditional to check for feature image and custom field?

I have this working for the most part, but some of the syntax is wrong someplace because when the post DOESNT have a thumbnail, it still prints that last echo and closes a div outside of the ...
0
votes
1answer
154 views

Display Latest Post on a Page Conditionally

So I'm wondering exactly how I could display my latest post on a page only in certain conditions. I've been looking over the conditions page in the codex, but I'm not seeing how I could do what I have ...