The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
2answers
3k views

How to conditionally enqueue a stylesheet only for a certain page(s)?

Before I get started, I want to acknowledge that there are some really good articles that are targeted at how to conditionally enqueue scripts based on page/post content. WordPress Plugin ...
1
vote
1answer
213 views

How do display simple page for printing product info? [closed]

I'm using WP 3.1.2 and latest e-commerce plugin. Now I'm stuck at creating simple page for printing product info. It has to be only product information with not WordPress header and footer. The pop up ...
2
votes
3answers
6k views

If Post Type equals, then display X content

I just need to say in single.php if post type = x then display y. Else, don't display it.
1
vote
1answer
655 views

Condition function for is parent category?

I have a parent category with many sub-categories and I am trying to display the page differently when it is in that specific parent category. But instead of writing the code like ...
0
votes
1answer
412 views

Using PHP Increment and Conditional Statement to Alternate Loop Background

I'm trying to alternate the background on a theme page that is displaying a custom loop: $args = array( 'post-type' => 'portfolio', 'posts_per_page' => 10 ); $loop = new ...
0
votes
1answer
88 views

Problems with my conditionals in single.php by category

In my single.php file I would like to have a conditional that checks for the category of the post and display certain images and layout. Here is what I have: http://pastebin.com/dy6TE1yr
1
vote
1answer
102 views

Conditional Statement - Best Way to Remove Nav on Contact Page

I was thinking of removing navigation on my contact page. I was thinking of inserting a conditional statement and an inline CSS style to "display: none;" if the page template was the contact page. ...
0
votes
2answers
456 views

Dynamically output a class to an anchor tag depending on what tag is chosen

Not sure if this is possible, but what Id like to do is have the ability to output/add a class to an anchor tag depending on what tag I choose when creating the post. My reasoning behind this is to ...
0
votes
1answer
154 views

is_front_page breaks with url parameters generated by a plugin

I have a website that displays a specific layout feature only on the homepage, and this is working fine. However, the client has suggested that they would like the website to be bilingual, and so I ...
0
votes
2answers
525 views

Show image next to the comment author if have certain role

I want to create a badge image for comment author of a certain role, say, Editor. I want to style comments of users with the Editor role differently than comments of non-registered or lower-level ...
1
vote
2answers
2k views

is_front_page, is_page('slug'), is_page(id) not working

None of the following are working to display conditional format in the sidebar when the current page is the home page: is_front_page, is_page('home'), is_page(id) I added an else clause which is ...
0
votes
3answers
282 views

Conditional for Custom Post Types

I have a query that pulls custom post types and regular posts, but how could I tell it to offset just one post type in the query? My query: <?php query_posts( array( 'posts_per_page' => ...
1
vote
1answer
1k views

Need help on creating If-statement for custom meta fields

I'm using Wordpress. I have a movie review website called Filmblurb. For my blog posts, I'm trying to create posts with different categories. Under the "Reviews" category, I have a "Details" box that ...
1
vote
1answer
242 views

Conditional Shortcode image display

Got a problem with a shortcode.. i probebly dont know where & how to set the condition so it will display the right image according to the topic / category of the toturial.. Help Plz :) function ...
0
votes
1answer
125 views

Using conditional statements in place of custom Page templates

How do I use if/ else statements instead of custom Page templates? For example, I create content for static Pages that I want to look different from other static Pages. So instead of using ...
0
votes
2answers
2k views

Conditional Statement - check if post has an attachment image

I'm working on a conditional statement (in a loop) that looks for a featured image then grabs a default image if there is none, which I have figured out. But, I also wanted a way to pull the first ...
0
votes
1answer
42 views

Generating images from an array of categories

I'm using the following code to display images based on the category id: <?php if (is_category( 'web-design' )){ ?> <img src="<?php bloginfo('template_directory'); ...
0
votes
1answer
159 views

Date-Based Conditional Tag

I'd like to have a conditional tag that is something like this: <?php if (is_single()&&is_older_than_october_2011()){do this}; ?> The part I'm trying to highlight is the ...
3
votes
2answers
792 views

Display only certain posts based on visitor's country?

Is it theoretically possible to have the following feature? Each post has a country code. When a visitor comes in, the system will determine the visitor's country code. Then when the page renders, ...
0
votes
2answers
929 views

if/Else have_posts Else fails to echo message to page

Scenario: Page displays a list of titles for a custom post type (video) with a selected "category" (in the taxonomy its called the subject). For example videos with the subject of "creative" Problem ...
1
vote
2answers
478 views

Conditional custom field query

I'm working on a job board-type site, and the client want to sell featured posts. They want the featured posts to expire from showing up in the "featured" section after a predetermined period of time, ...
2
votes
1answer
383 views

Custom Menus, Widgets & Conditional Statements

I'm employing custom widgets for my client because it's easy and they have several menus they need to create specific to site sections. I then want to allow them to add to the custom menu dynamically ...
1
vote
2answers
177 views

to create own conditional tags for business directory in wp

i want to create conditional tags for the business directory categories as the conditional tags which are provided are for normal categories.which do not work for the business directory categories.can ...
1
vote
2answers
322 views

Conditional display for custom fields/taxonomy

If there's a value for the custom field, I want it to display the value. If there's no value for the custom field, I want it to display "N/A". I have this working for custom fields but cant replicate ...
0
votes
1answer
154 views

Message box when accessed from iPad

I am still looking for a solution for this and can't seem to find it. I have the following code to start, but am not sure how to write the function to fire off a .js file. I need this to work on one ...
0
votes
2answers
262 views

Check if has pages?

So hard to find this info... I'd like to know a way to find out if there are pages. Something like: if (has_pages()) { /* do something */ } I can't find a reference to any similar function... how ...
1
vote
3answers
982 views

How to show my sidebar in specific page only?

I would like to show a plugin in a specific page's sidebar only. For Example: I have the pages like .. home about us sub page 1 sub page 2 sub page 3 sub page 4 UPdate: i want to show, ...
0
votes
2answers
409 views

Is there a PHP function that can match anything after the given URL, so my IF statement will work in each instance?

I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as /page/2/, my query breaks because the url isn't ...
1
vote
1answer
758 views

how to know if the post has pagination (<!--nextpage-->) or not

i need a solid solution for checking if a post has pagination or not, regardless of the number of current page in the pagination, and even if the post is in the first page of the pagination. the check ...
1
vote
4answers
4k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with ...
5
votes
7answers
5k views

wp_enqueue_script adding conditional statement not working

This is the code im using in my functions file: add_action('init', 'sort_out_jquery_pngfix_frontend'); function sort_out_jquery_pngfix_frontend() { global $wp_scripts; if(!is_admin()) { ...
0
votes
2answers
349 views

Conditonal statement for iPad

I need to hide the branding section of my blog, but only when someone is viewing it from the iPad. I am not sure how to attack this. EDIT: the function remove_access currently works in my template, ...
0
votes
1answer
1k views

If have posts a week old, display, else display a different loop

This is what I have. <?php $week = date('W'); $year = date('Y'); $projects_in_news = new WP_Query( array( 'post_type' =>'news', 'posts_per_page' ...
1
vote
1answer
1k views

Can shortcodes contain conditional statements? Even without them my shortcode renders blank page

The following code is supposed to allow for a shortcode that includes many attributes, but not all of the attributes may always be present in which case I do not want the containing element to show ...
1
vote
3answers
432 views

A function like is_page() but returns true if on any sub page of given page

In my header I use this code: if(is_page("stores")) { // Do something } I run some code if on the page stores but what I want to do is run that code if the page is stores or any page that is a ...
0
votes
1answer
112 views

Checking for custom field in admin pages

I am loading some scripts conditionally for the admin section with : if (is_admin()) { wp_register_style('admin_js', get_bloginfo('template_directory') . '/admin.js'); ...
0
votes
3answers
1k views

Hide a nav menu item based on get_user_meta results

I'm trying to hide a navigation menu item under certain circumstances. Specifically, if a user is logged in AND has already registered their product bar code, I want to hide the 'Register Kit' link ...
1
vote
1answer
1k views

Create a new usermeta field for users

How do I create a new usermeta field with a drop down selection values? Im want to create a conditional statement for all users with a certain value of the new custom field I want. For example, The ...
0
votes
2answers
368 views

Show label for value only when value exists, basic php

I currently have this, <?php $meta = get_post_meta(get_the_ID(), 'rw_agentPhone', true); echo "office:"; echo $meta; // if you want to show ?> Which is fine provided there is a value for ...
1
vote
1answer
86 views

WP for main site and two blogs - implementation

I'm working on an open-source software project and hoping to move and combine some disparate sites that it's on. Currently there is a main info/code site. Then there are two blogs for implementations ...
0
votes
2answers
139 views

Trying to use Ternary operators with WP Conditionals

Hi I am trying to use ternary operators with WordPress condtionals, using the code below, but it's giving me a PHP error, what am I doing wrong? echo is_home() : '1' ? '0';
1
vote
2answers
628 views

wordpress is_page() problem

I want to load a .js file only on a specific page in Wordpress 3.1.2 So I use in functions.php function my_init_method() { if (is_page('myinfopage')){ echo "yeeessssssss"; ...
0
votes
1answer
213 views

Exclude a category from a query that includes its parent category

I am trying to use ids to control the structure of the output of my categories. I need to exclude a category that is part of the parent category that is being queried. What I am trying is : ...
1
vote
1answer
747 views

functions.php conditional tag - only show in single.php?

//Geo Map add_action( 'woo_post_inside_after', 'my_geo_mashup' ); function my_geo_mashup() { global $post; if ( in_category('listings') ) { echo GeoMashup::map(); } } Works to ...
2
votes
1answer
752 views

If function exists, and array is met, echo function?

I have a function like the following: <?php echo my_custom_function( array( 'category_url'=>'My Special Category' ) ); ?> It pulls data from the "My Special Category" and displays it. I ...
2
votes
7answers
9k views

Display navigation menu item conditionally based on user capabilities

I have one "branch" of my main site's navigation tree that should only be accessible to a set of registered, logged-in users. I understand how to query a user's role and capabilities. This question is ...
1
vote
2answers
125 views

can't use the page_test method to check pagination

I've tried to follow the example for Testing for paginated Pages but i don't know why it isn't working. i put it in the single.php file for post detection. i don't know why the page_test is broken. ...
2
votes
1answer
680 views

Conditional tag affecting taxonomy term and its children?

I am wondering how can I write a conditional tag that affects a custom taxonomy slug and its children? Found this in Wordpress Codex: is_tax( 'flavor', 'mild') When the archive page for the ...
4
votes
1answer
4k views

How can I determine if a post has an image attachment?

As far as I know, there's not a simple function that will return true if a post has an attachment. With that in mind, what's the best way to determine if a post has an attachment (or even better, has ...
0
votes
2answers
416 views

How do I test whether [gallery] is empty?

How do I test whether there are any images attached to a post? I'm using the gallery shortcode, but I want to put it in a conditional so the surrounding styling isn't displayed if the gallery is ...