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

learn more… | top users | synonyms

1
vote
1answer
511 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
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
444 views

Display a widget on a specific type of archive

I have two sidebar widgets, I need to display 1 widget on the archive pages for the standard post categories and the other widget needs to show on just the archive pages for a specific custom post ...
0
votes
2answers
40 views

Conditional in foreach loop is outputting content twice

I have a website that displays a slideshow using custom fields and the Slick carousel, using the code below. <?php $entries = get_post_meta( get_the_ID(), '_mysite_homepage_slider_group', ...
0
votes
1answer
482 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
1answer
478 views

Custom Function for Portfolio Archive Template With Conditonal Tag

Can't work out which conditional tag to use to add a page title to the portfolio archive page which uses custom posts types. This doesn't work: if( is_archive('portfolio') ) echo '<div class="...
-1
votes
1answer
32 views

Use slug rather than id for $post->post_parent?

Is there a way that, when using $post->post_parent in a conditional, the parent slug can be used rather than the parent id? I'm using the code below to prepend some page/post titles with parent info, ...
-1
votes
1answer
27 views

Advanced custom fields Repeater conditional statement not working [closed]

Even if no value for a field is entered my elements inside my echo still show inside my conditional statement. Thinking that is just checking if the field exists rather then checking if a value is ...
0
votes
1answer
21 views

Need to adjust condition to say if I'm pulling categories from a post, to pull only the first one

I have a condition to pull posts based on category so when in my single.php users can see related posts based on categories, but the problem here is if someone posts a post with more than one category,...
1
vote
1answer
47 views

Modify conditional titles to include parent and page number

Using conditional titles with title-tag rather than wp_title(), how do I add the immediate parent or ultimate grandparent to the title and,for multi-paged posts, the page number? When using wp_title()...
1
vote
2answers
34 views

How can we use conditional tags in plugins?

In the plugin, The css file loads sitewide by default, I want to load it only on the Single post. the conditional tags, i.e, is_single() isn’t working in plugins, any idea how can we achieve that?
5
votes
2answers
885 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.
20
votes
4answers
13k 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'] ?
-1
votes
0answers
28 views

WordPress redirecting issue using is_page and logged_in

I am using buddypress and want to redirect all logged in users to their profile page when they try to access login page. Below code only works if I check logged in user but not with is_page(). Also ...
0
votes
1answer
12 views

conditional based upon the count of current user's published custom posts

I have this conditional snippet that does something is the current user has not published a normal post. But I'd like to change it so that it counts a custom post rather than a normal post. <?php ...
0
votes
1answer
36 views

Conditional Tag for has post [closed]

I am quite new to all the programming, and I am now stuck with the following. I installed the plug-in If Menu which lets you show specific menu items when Conditional statements are true or false. I ...
0
votes
1answer
51 views

How to make a wordpress loop file that displays posts based on certain conditions

Am recently trying to learn the framework aspect of WordPress,so i want to build a user homepage that only displays posts from other registered users, but the posts that will be displayed will have to ...
0
votes
0answers
31 views

Checking supported arguments in theme features ( current_theme_supports )?

I think I wan't to use get_theme_support since it returns an array of arguements where current_theme_supports doesn't (as far as I know). For example, here's a theme support in genesis for adding ...
1
vote
0answers
26 views

Loading template parts conditionally in Customizer

Here are my issues: I have layout options in customizer for full width or two columns. For fullwidth sidebar will not be loaded. The problem is if the setting is currently on full width when ...
0
votes
1answer
59 views

Check if CTP category taxonomy is set in shortcode

I have created a custom post type with the ability to add categories (taxonomy). Taxonomy function create_cat_tax() { register_taxonomy( 'cpt_cats', 'cpt_faqs', array(...
2
votes
2answers
725 views

Current post's author name in the author meta tag

I am trying to add the current post's author as the content for the meta author tag. I wrapped this particular meta in an is_single condition and then tried: <meta name="author" content="<?php ...
0
votes
1answer
80 views

Check if the current shortcode is being used in a widget

How can I check if the current shortcode is being used in a widget? I need to disable some shortcode options that are not allowed in a widget. Someone know how?
0
votes
1answer
71 views

Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu

The Challenge I have been trying to write a filter that applies (prepends a string) to (a) post titles of a certain post type and (b) to that same post type WordPress admin backend for use by an auto ...
0
votes
0answers
40 views

TinyMCE custom button on post-new.php screen

Iam building a small slideshow plugin. For this I registered a new post-type which is called "prfx_slide". And also set-up a shortcode function so that I can use the slider as a shortcode. With the ...
0
votes
2answers
30 views

Show all tags NOT applied to post

I'm working on a checklist within wordpress – I have a huge list of posts and I want to tag them with checks that have been done for the post. However, I want to display all the tags not applied on ...
55
votes
6answers
128k views

If is custom post type

I am looking for a way to test if a post is a custom post type. For example, in say the sidebar I can put code like this: if ( is_single() ) { // code here } I want code testing for only a ...
0
votes
3answers
40 views

How to apply a function if conditon a & b [closed]

I want to apply a function if post is updated and if post author id is not 1. For this i tried many functions like <?php if (get_the_modified_time() != get_the_time()) && ( $author_id != 1 ...
0
votes
1answer
41 views

How to add conditionals for IE browsers between certain versions?

I know that wp_script_add_data and wp_style_add_data are the correct functions for adding IE conditionals. For example, this: wp_script_add_data( 'foo', 'conditional', 'lt IE 9' ); Would get you ...
0
votes
1answer
41 views

Conditional tags returning different results for different areas on a page?

I have a custom template. I want to output some JavaScript based on the type of page I am on. My current setup includes a static front page, with a template assigned it to it. This template is also a ...
0
votes
2answers
39 views

is_singular() equivalent for backend

I use the conditonal function is_singular($my_post_type) inside my plugin and it is very convenient. The problem is that is doesn't work backend. Is there an alternative that works frontend & ...
1
vote
3answers
68 views

If (category / tag checked) then (display header2php)

I have 3 headers (header.php, header2.php, and header3.php). I want to always display header.php at the top. Below header.php, I want a second header to display depending on what category the post is. ...
8
votes
3answers
1k 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
0answers
27 views

if IS and IS NOT statement not having desired effect on custom taxonomy

I'm not a developer, I'm essentially learning as I go. I'm trying the following statement, and it's executing but not having any effect: function share_discount( $download_id ) { if ( is_singular(...
1
vote
1answer
24 views

Conditional tags or Multiple files

If the official themes and Underscores are some sort of a guide, one would notice that multiple files with little differences are preferred over conditional tags (archive.php, search.php, category.php,...
0
votes
2answers
77 views

Inserting HTML to close and open divs in WP_Query loops

The output I am trying to achieve is this: <div class="row"> <div class="small-1 large-4 columns"><a href="some link"><img src="some image"></a></div> <div ...
0
votes
2answers
19 views

page single conditional

Using underscores, I made a lot of small, simple custome themes. I was more interested in CSS and simple layout modifications, but I'm not used to vanilla PHP. What I need I think is a simple code, ...
0
votes
1answer
26 views

Manipulating cookie on specific taxonomy archive page

I have this code to set cookie when user on the taxonomy archive page called 'term-country' if (is_tax('term-country')) add_action('init', 'my_setcookie'); // my_setcookie() set the cookie on the ...
0
votes
1answer
22 views

Blog Posts vs Static Page (conditional statements)

I want to determine when it's the following page: Front page displays the Blog page Front page displays the Blog page + subpages: /page/2/... Front page as static page Blog page as static page Blog ...
1
vote
1answer
975 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
1answer
42 views

Three variables on conditional tags

I'm trying to return $ad_code if three variables are present, but it doesn't allow the third variable I'm trying to add. I want to exclude a category. I am trying to use (in accordance with ...
0
votes
1answer
26 views

Conditional Tags for specific category of custom posts

How would I show a sidebar only if the post (a custom post type) belongs to a specific category of that custom post type? I was looking for something like: if ( is_singular( 'my_custom_post_type' ) &...
0
votes
4answers
589 views

Function to echo (or display?) wordpress tags in the head section

I can't figure this out but I'm trying to echo the post Tags of the post in the <head> section. This code resides in the <head> section of the site. Basically I want the post tags to ...
0
votes
1answer
46 views

Conditional Tags - Multiple Categories

I need to have all News posts show a category header (while not showing the post title). The following piece of code seems to do the job: if($category[0]->name == 'News'){?> <script> ...
7
votes
5answers
405 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
1answer
77 views

how to display featured image for single post for a specific category

I used this function to display featured images on top of single posts and it works great. But I need it to only apply to the category 'team' with an ID of 31. I have tried every possible combination ...
0
votes
0answers
34 views

Adding condition to a Form plugin

I am trying to figure out how to get my Form plugin which I had it customized to do a certain thing for a specific form (lets sat form #100) to not to do the same on other forms that are being created....
0
votes
3answers
5k 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 ...
0
votes
0answers
56 views

Can you check if a post WYSIWYG field has an image in it?

I'm using Advanced Custom Fields and a WYSIWYG field type. Can you determine via php if that field has an image in the content OR is there a better was to evaluate this. For example, if I upload an ...
10
votes
2answers
5k 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?
1
vote
1answer
205 views

How to check if a post “does not have term” in conditional statement?

We know that we can check if the particular post has a term by using this code: has_term('term', 'taxonomy', $post->ID )) { I was wondering if there is a code to check if a particular post does ...