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

learn more… | top users | synonyms

1
vote
1answer
27 views

Conditional tag search-no-results

Is there a way to make a conditional tag that tests if it is search-no-results page? I know that there is a function to check if is_search() page: if(is_search()){ echo "search page"; } But I ...
1
vote
1answer
228 views

Auto Add Image Title,Caption,Alt Text,Description while uploading Images in WordPress

Can anyone tell me how to auto fill/add same image title in title, caption, alt text and description while uploading any image in my WordPress Posts.
1
vote
1answer
1k views

Is_search not working on search results page

I have an extra submenu with this code in the sidebar: if(is_404() || is_search()) : echo 'should be empty'; else : if($post->post_parent == '68') $children = ...
0
votes
1answer
13 views

Conditionally print css style in Wordpress

I posted this on Stackoverflow and as suggested I am reposting it here if thats ok. Didnt knew there was a Wordpress section of the site :) I am working on a Wordpress theme and want to give the ...
0
votes
1answer
11 views

Hide breadcrumbs on specific pages

Can anyone help me to hide breadcrumbs from certain page ID's? I'm using the Breadcrumb NavXT plugin. I've only found out how to hide it from the home page. I'm using this code in my header.php: if ...
0
votes
2answers
32 views

Dequeuing scripts for all pages but the home page

I'm trying to dequeue some scripts from a plugin that I only need for the home page. For the home page, I'm using a file called front-page.php with this on top to make it a home template: <?php /* ...
9
votes
2answers
3k views

Toggle admin metabox based upon chosen page template

I'd like to have a custom field interface show up only when a certain template is assigned to a particular WordPress page. Any ideas?
0
votes
1answer
24 views

unsetting required fields in the comment reply form

Is there a way to make differences between the normal comment form and the reply-to-form? For example, I added a set of required radiobuttons to the form which make rating by commenting happen. Now, ...
0
votes
1answer
21 views

How can I display a div ONLY if it is not a certain term page

Ok so I have two Custom Taxonomies of "Types" and "Countries" with dozens of terms. I basically use the terms of "Types" and "Countries" as a filter for my products in my taxonomy.php Now Those 2 ...
2
votes
1answer
361 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
1answer
24 views

Pre Get Posts - Difference between conditional() and $query->conditional()?

This may be a poor question but inside pre_get_posts() is there any real difference between $query->conditional() versus just adding the conditional() ? Take the following example: /** Themes Pre ...
13
votes
2answers
6k views

Check if we're on the wp-login page?

How can I check if the current page is wp-login.php or wp-signup.php ? Are there more elegant solutions than using $_SERVER['REQUEST_URI'] ?
0
votes
1answer
349 views

If tag exists, then echo once

I have the following code and I'm trying to check to see if a specific tag exists, and if so, I need to echo it once. The problem is when the tag exists in multiple places, it echos multiple times. ...
0
votes
2answers
2k views

Conditional tags issue for multiple is_page() conditions in sidebar.php

I've been pulling my hair out today trying to get this right. Basically I have a sidebar, which makes requests to individual files (such as sidebar-home.php, sidebar-residential.php) and different ...
0
votes
1answer
11 views

My Conditional Tags not Working

I'm just a starter in WordPress. I found the one I'm looking for but I can't make it work. I want to add a script when the travel page is shown and it's hidden when the user navigates to the rest of ...
0
votes
0answers
30 views

Custom taxonomie conditionnal

I need to create a conditional with custom taxonomy/tag. Let me explain the concept: The website is based on user's contribution (fitness/body building performances). A member create a new post and ...
1
vote
1answer
43 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. ...
0
votes
1answer
22 views

Comparison Operators not working for conditional author post thumbnails

I'm trying to place the default featured image on the blog index page with an image to be determined by who the author of the post is. For some reason I'm getting the image for $author_id=2 even when ...
1
vote
1answer
62 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
0answers
31 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
43 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
31 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
30 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
33 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 ...
4
votes
3answers
219 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
44 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 ...
1
vote
1answer
531 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
0answers
28 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
44 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
44 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
42 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 ...
-1
votes
1answer
63 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 ...
1
vote
2answers
656 views

Conditional tag in Widget Logic for checking if top level page or if subpage

I'm using the Widget Logic plugin to show widgets on certain pages using Wordpress Conditional Tags (or any general PHP code). What I would like to do is only show a widget on child pages, not top ...
0
votes
2answers
28 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
103 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
113 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. ...
2
votes
1answer
338 views

Check if page/post has any anchors that link to an image jpg/gif/png

What I'm aiming to do is add fancybox to a site I'm developing, but I only want to enqueue the JS/CSS etc if the page/post needs it. My thoughts are that I would need to check all the anchor tags on ...
0
votes
1answer
20 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
77 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
19 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
44 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 ...
2
votes
1answer
1k views

Problem using is_single() to enqueue script from functions.php

I'm having trouble only adding scripts to single post pages. I need to both include and exclude certain scripts using is_single() but it doesn't work either way I try it. I have the template tag on ...
0
votes
2answers
39 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
1answer
50 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
81 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
45 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
90 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
1answer
379 views

wp_enqueue_scripts called twice?

I had some problem with WP recognizing a is_single condition for loading scripts called in function.php. I put a error_log(is_single()) to check what was going on. When opening a post page the log ...
0
votes
2answers
55 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 ...
7
votes
5answers
303 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()) { ...