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

learn more… | top users | synonyms

0
votes
1answer
8 views

Advanced Custom fields - select field [on hold]

abit of an issue, (abit of a php noob) ACF documentation is not the best to follow. I'm trying to get conditional statements working with acf SELECT field. ...
0
votes
0answers
17 views

Widget area to full width layout only

I want to add a new widget area that will only display if the layout is full page (no sidebars). There doesn't seem to be a WordPress conditional based on layout. Is there a way to do this?
0
votes
1answer
52 views

Conditional tag for all categories of a custom post type

I need a conditional tag which returns true on all categories added to a specific custom post type. Tried dozens of variations using the conditional tags from the Codex but still stuck. What i'm ...
0
votes
1answer
17 views

ajax wp_query conditional tags not working

I'm trying to ajax wp_query, I got success getting posts for home page with the following code. Then I added conditional tags to modify the query for the other pages like Category page the problem ...
0
votes
1answer
21 views

Load slideshow.css file only if Slideshow is checked / on

I use <?php if ( get_option('mytheme_slider') == 'checked') { get_template_part( 'partials/slider/slider-java-script' ); } ?> to include the slider-java-script.php template part into my site. ...
0
votes
1answer
18 views

If tag equals then show else show

In my WordPress I have a page template called: single_jobs.php In the template is shown a contact formular. Linked in the template file like this: <?php echo do_shortcode( '[contact-form-7 ...
0
votes
0answers
17 views

is_page_template() doesn't work with excerpt_length filter

I am tring to set a different excerpt lenght for the pages that use an specific page templates using excerpt_length filter. This is the code: add_filter( 'excerpt_length', 'nmd_excerpt_length', 999 ...
2
votes
0answers
55 views

What are the effects on loading times when conditionally loading and concatenating scripts? [migrated]

Suppose you have a script in your theme that you always need on every page - say 'animate-menu.js' (10KB) - and you have one that you only need on one specific page - say 'validate-contactform.js' ...
4
votes
3answers
140 views

the_content and is_main_query

I am filtering the content with the the_content filter. Everything works perfect, excerpt that my changes are applied to custom queries as well. My changes appear in the sidebar as well if the widget ...
0
votes
1answer
33 views

How to define Og Meta Tags in header using conditions [duplicate]

I'm trying to configure my Facebook Og meta tags in my header so I get a different result on the type of page I want. I've been hitting some road block that searching through google haven't been able ...
0
votes
0answers
20 views

Conditional check for embedded video in the_content

I have a site where single.php displays the post stuff in this order: title featured image the_content I would like to remove the featured image IF the_content includes an embedded link (f.eg. to ...
0
votes
1answer
35 views

If less than IE9 [closed]

I've setup two Sidebars, am running a php browser detection plugin: http://wordpress.org/plugins/php-browser-detection/ and am trying to use the code below to show the countdown-ie sidebar on Internet ...
0
votes
1answer
34 views

How to add a filter conditionally based on page related Conditional Tags

I am developing a WordPress plugin and can't conditionally add filters based on the conditional tags. This is my code: add_Action('init', 'determine_location'); function determine_location() { $d = ...
0
votes
0answers
20 views

Show different number of posts per page in tag archives

I am using the following code out of loop to show one post per page in tag archive. <?php query_posts($query_string."&showposts=1") ?> However, I want to show recent posts as 10 posts ...
0
votes
2answers
21 views

Conditional tag for attachment posts

In Wordpress single.php post pages are both for media attachments (e.g. http://domain.se/postname/imagename/) and blog post pages. What conditional tag can I use to determine if a post is not a media ...
0
votes
1answer
79 views

Cannot Use is_single() and is_admin in functions.php

I'm using a Thematic childtheme for my wordpress website, and instead of putting all my functions into the functions.php file, I thought I make it more organised by creating multiple other function ...
0
votes
2answers
70 views

deregister scripts on certain page

i need to exclude certain scripts from running on a certain page. i have tried this code but it's not working - when i inspect the page the scripts are still being loaded into the footer of my page. ...
0
votes
1answer
15 views

Using conditional staements to load plugins

I'm having some conflicts I think with a couple of plugins I have written that use ajax. As they load their resources on every page rather then just when needed I think it's causing problems. What's ...
0
votes
2answers
57 views

If Month=Particular month display content [closed]

I want to use conditional tag to display content according to month. Such as if it is April, it should show something else something else. Right now I am using : <?php if(is_month() == '2' ) : ...
0
votes
1answer
16 views

How can have a conditional template tag based on the main loop within a secondary loop with new WP_Query(), using get_template_part()

What is the best practice methodology for referencing the main loop from within the context of a secondary loop within a partial called via get_template_part()? For example, say my homepage contains ...
0
votes
0answers
34 views

Adding CSS styles to Admin Area PAGES only (not POSTS or CPT)

I am using this to load css styles in the admin area (for any user who is not an administrator): function wpse_admin_styles() { if ( !current_user_can( 'manage_options' ) ) { echo ...
-1
votes
1answer
62 views

Trouble with conditional tags

I've got some code I want to run on every page other than the blog page and the archive page. If I use <?php if ( !is_home() ) { ?> The code correctly doesn't show on the blog page. If I ...
0
votes
1answer
42 views

Conditional category & tag statement

I'm just working on a "quick" change to the blog-entry-subtitle of specific posts in a category on my wordpress website. I'm hoping to have "Published in Orchard and Vine Magazine on:" instead of ...
0
votes
2answers
38 views

WordPress Single Conditional for Search Page

Is there a way to filter single.php so that if someone came from search.php it would display one thing, but if they came from anywhere else it would display another? Thanks, Josh
0
votes
2answers
68 views

Conditional css for custom post type

I'm using a wordpress theme which uses custom post types for portfolio items and "sets" to categorize them. When I hover over a "set" to edit, it reveals this at the bottom of the browser: ...
0
votes
2answers
42 views

Cannot retrieve active members only

Below is a page template where I'm trying to retrieve active members metadata (of Restrict Content Pro). Displaying users' meta is working just fine; but I can't get ONLY active members to display, ...
0
votes
0answers
77 views

Conditional tag to check if 'page.php' is being used?

I'm trying to check whether the page.php template is being used or not. I've tried is_page_template( 'page.php' ) but it doesn't work. I also can't use is_page() because I only want to do something ...
0
votes
2answers
46 views

Is this a bad approach to add conditional comments to wp_head?

Why people say this is a bad approach to add conditional comments to wp_head? For example: function add_ie_html5_shim () { echo '<!--[if lt IE 9]>'; echo '<script ...
0
votes
0answers
29 views

Issue getting gettext to work with conditional statements

I've been trying to apply a gettext filter to return two different results for different product categories (or read as categories for posts, non-woocommerce specific). I cant seem to get it right. ...
7
votes
5answers
288 views

Actions, functions and conditionals

When developing themes and plugins it is sometimes neccesary to add some functionality to some hook using conditional statements. Example: function my_custom_function() { if( is_home()) { ...
0
votes
0answers
100 views

Identify a Woocommerce page by Wordpress conditional tags

we have a website running on WPMU, and the main site is using Woo-commerce and the sub sites doesn't use that. I use conditional statement in my meta title with following code: <title> <?php ...
0
votes
0answers
33 views

is_admin() triggers error

I've a plugin which includes other files and it looks like that : if( is_admin() ) { require( DIR. 'file.php' ); } In this file I run a class. This class is initialized on plugins_loaded. ...
0
votes
0answers
12 views

setting global and using as argument [duplicate]

I've set a global variable in functions.php like so: $cat_args = array('cat1', 'cat2', 'cat3'); and tried to use it in a template file: global $cat_args; if is_cat($args): //do stuff endif; The ...
0
votes
0answers
8 views

Tag, Category and Single Conditionals

We have this sample: This function call Backgrounds in different places in the WP I add it to the <body> <?php function backgrounds(){ global $wp_query; if(is_home() || ...
0
votes
2answers
56 views

Check if user registered more than a month ago

How would I go about checking if current user registered more than, say, 30 days ago? I would like to display certain content only to that group of users. Thanks very much in advance for your help.
1
vote
1answer
238 views

Conditional tag is_page with a custom post type

Accordingly to the is_page documentation, supplying the slug as an argument WP can tell me whether the current page is the one represented by the slug. Perhaps I am using the wrong slug? However I ...
0
votes
2answers
47 views

Entirely Different Functions.php per Page?

Is it possible via conditionals to load entirely different functions? i.e in the functions.php you have a conditional that loads in an include for the old functions, then another that loads in the ...
0
votes
1answer
42 views

Difference between is_user_logged_in and $_session['uname']

I am writing a condition to check if a user is logged in, not sure which of the below condition to use : if(!is_user_logged_in()){ And if(!isset($_SESSION['uname'])){ Basically need to ...
1
vote
0answers
42 views

Adding Controls to Theme Customizer If Certain Page Template is Active

How to Conditionally add controls on Theme Customizer panel. Conditional like is_page() or is_page_template() obviously does/will not work because the page is being shown is customize.php. Code ...
0
votes
0answers
27 views

Conditional within a public function within a loop

I am using a plugin to build widgets that includes images. Unfortunately it doesn't allow me to resize the images. I tried by adding a conditional but since it's in a public function and within a ...
0
votes
1answer
122 views

“if parent category is” conditional?

I searched through the codex but couldn't find anything helpful. I tried the code below but it didn't work. The default sidebar still shows up for all category pages. <?php ...
1
vote
2answers
147 views

Post.php - Conditional statements for new post and edit post

This question came up when creating a custom meta box for the edit.php page. Is there a conditional statement to target posts that are already exist vs posts that are not created yet? The idea: If ...
1
vote
2answers
109 views

Conditional tags inside a class

I have a couple of functions that I now combined in a class. The reason for that was that all these functions go towards one goal, and it is more appropriate way to use the globals between these ...
1
vote
3answers
106 views

Multiple Conditions for Child Page Title

I've been trying to work with Conditional Tags and cannot wrap my head around this problem. PHP novice here. On sub-pages I need to display the parent page title as well as the page title. I have it ...
1
vote
2answers
38 views

Conditional IF statement not returning true even though echo of $user->province is correct

I am having a problem with an if statement which I have now tested many times over. $user_query = new WP_User_Query( array( 'role' => 'Subscriber' ) ); if ( !empty( ...
0
votes
1answer
58 views

Else statement not triggering after a failed if statement

I am working on a client site and the statement I wrote 6 months ago seems to have stopped working after the WordPress update to 3.8 I can't see or figure out why. There are no errors appearing it ...
0
votes
2answers
362 views

WP_Query and is_page_template() conditional

I have a custom query that goes looks like this: $temp = $wp_query; $wp_query = null; $args = array('posts_per_page' => 5, 'post_type' => 'gallery', 'post_status' => ...
0
votes
1answer
57 views

Conditionals in WP_Query

What I'm trying to do is this: If in the last 7 days someone has added a post in the category 'featured' display it in the loop. Otherwise, display the most commented post from the last seven days. ...
0
votes
2answers
51 views

Try to run a function only on Home

I'm trying to run disable auto p filter on only my home page. In my functions.php file, I added this snippet: function removeP(){ if ( is_page( 4 ) ) { remove_filter('the_content', ...
0
votes
1answer
60 views

How can I hide the category term for posts with none set?

I'm trying to hide the word "Category:" from the metadata on the Twenty-Eleven theme's footer, when I don't have one set for a given post (sometimes I will manually remove the "Uncategorized" ...