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

learn more… | top users | synonyms

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
246 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 ...
26
votes
6answers
68k 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 were I could do ...
1
vote
1answer
101 views

disable comments if array exists

This is the code which is registering the function for rewrite_endpoints(): function wpa121567_rewrite_endpoints(){ add_rewrite_endpoint( 'comments', EP_PERMALINK ); add_rewrite_endpoint( 'stats', ...
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'] ?
2
votes
1answer
320 views

Bulk add tag (or any sort of label) to posts who have custom excerpt

The situation is the following: The blog as of now has 2200+ posts. In the beginning (2007/2008) I was using manual excerpts where I would put an image and a little bit of text. The manual excerpt ...
1
vote
1answer
3k views

If on term-page -> get the current term?

I'm trying to write a kind of "breadcrumb" function in my "functions.php" I'd like to query if I'm on a term-page and if so I want to print the current term I'm in. By "term-page" I mean the ...
0
votes
1answer
835 views

is_active_sidebar() Always Returns False

I've never gotten is_active_sidebar() to work, no matter if there's widgets in the sidebar or not I always get false returned. Currently I'm creating a sidebar for each top level page: ...
0
votes
1answer
891 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 ...
-1
votes
1answer
473 views

what is the action hook code to supporting product category condition in single product page of woocommerce?

I want to display product attributes of 2 different product category with the help of conditional tags. But the condition was not working This is the condition that i given ...
7
votes
5answers
301 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()) { ...
5
votes
4answers
1k views

How to make plugin required in a wp theme without using php conditional statements when calling an individual function from that plugin?

One of my Wordpress themes requires a few third party plugins to run correctly. Most of the times I used to call functions from third party plugins using conditional statements like ...
-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 ...
4
votes
3answers
214 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 ...
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 ...
2
votes
1answer
365 views

Problem with “conditional tag”: if empty

I've been trying for a while now to make it so that there is nothing shown if there are no Related Posts. Currently the headline and the container (of course empty) are displayed. Like I said I tried ...
1
vote
2answers
144 views

is_archive() doesn't work on public query var archive pages?

Public query vars are those available and usable via a direct URL query. E.g. example.net/?category_name=tech&tag=gadgets But doesn't example.net/?category_name=tech&tag=gadgets show ...
1
vote
1answer
731 views

Conditional statement for parent, child and grandchild pages

I'm trying to figure out how to set up a conditional statement to check if the parent, child or grandchild is being displayed. This is what I've got so far: <?php if ( is_page( 'about' ) || '29' ...
1
vote
2answers
1k views

functions.php conditional tag only for custom post type

I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default ...
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
133 views

custom post type upcoming post and past post

I want to retrieve inside my archive-CPT.php most recent upcoming post ( post with status of future) and past post (oldest published post). This is how my archive-CPT.php is looking like: <?php ...
0
votes
3answers
323 views

Get template part based on custom taxonomy term

I have a custom post type and I'm trying to call up different variations of the navigation based on the custom taxonomy slug. I've done this fairly easily with normal posts, like so: <?php ...
0
votes
1answer
2k views

Why is wp-login redirecting to the home page when I use this function?

I'm perplexed; I can't see where I'm going wrong with this code. It should redirect any subscriber-level users back to the site home page if they try to access anything within /wp-admin - but not if ...
0
votes
1answer
189 views

How do I assign this filter to a variable? (Appending php & markup to the_content)

===I HAVE SOMETHING THAT WORKS NOW, JUST NOT CORRECTLY. PLEASE READ THE WHOLE POST, I AM GOING TO LEAVE IT ALL UP HERE BECAUSE OTHERS MAY BE ABLE TO BENEFIT FROM ME BUMBLING THROUGH THIS PROCESS!! I ...
-1
votes
2answers
82 views

changing default comment form arguments [duplicate]

I want to change the default comment form title_reply, label_submit ... just on my CPT without affecting the default comment form but I can't get it to work without affecting the default ones. First ...
-1
votes
3answers
2k views

alt attributes not showing on pages

I have downloaded a wordpress theme called livepuse, and unfortunately the alt tags are not showing on portfolio pages for my images. The website is as follows: ...