The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
2answers
1k 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
140 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
678 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
806 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
407 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
345 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
161 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
310 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
151 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
217 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
871 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
349 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
564 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 ...
0
votes
4answers
3k 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
4k 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
340 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
739 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
250 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
109 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
988 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
320 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
112 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
548 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
205 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
641 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
690 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
7k 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
605 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
3k 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
404 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 ...
0
votes
2answers
302 views

Conditional statement not working in function

Why doesnt this work ? I am trying to selectively load scripts but the second if statement is not loading them where it should. function my_init() { if (!is_admin()) { ...
1
vote
2answers
788 views

Function like in_category for custom taxonomies

I'm trying to display different content depending on the taxonomy that was been selected. For example I have a taxonomy named Type. Inside that taxonomy I have several different children, one is ...
3
votes
2answers
491 views

how to test for attached image

I am trying to find out whether or not a post has images. If it does, I then want to know if a featured image was specified for the thumbnail - if not, the get_thumb() function will assign an image ...
0
votes
1answer
131 views

Return count for characters in the comment and perform action based on the length

I am calling recent comments into my template with $comment->post_title the variable length is specified like this : SUBSTRING(comment_content,1,180) how could I write a conditional ...
2
votes
2answers
2k views

Loading Scripts on Specific Pages

In child theme I created a functions.php file that loads scripts and style files, the code is below. The section that loads libraries and scripts to all pages other than admin, in other words the ...
2
votes
1answer
590 views

How to make gravatar.com avatars conditional?

Problem: I am using custom avatars for registered users and my own locally-hosted image as the default gravatar. I want to stop WordPress making HTTP requests to check for gravatar.com images on every ...
2
votes
1answer
116 views

Search result conditonal tag

Is there a conditional tag (or a similar concept) that can tell me wether the search returned posts or not?
0
votes
1answer
177 views

Do not run this code on posts with a specific tag!

This is sort of complicated. I am looking for some php help related to WordPress blog. The basic requirement is that some HTML code (ad code) is not supposed to run on posts with a specific tag. ...
0
votes
2answers
291 views

Return function only on certain pages

I'd like this function to only return on certain pages. How might i do that? // Retreats Accordion function retreats_accordion() { ?> <!-- accordion root --> <div id="accordion"> ...
19
votes
6answers
46k 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 ...
5
votes
2answers
4k views

how to create a conditional content_width for a wordpress theme?

I'm trying to create a conditional statement for the content width in the functions.php of my theme. So some categories will have a content_width of 580, some will have 900. This will make the oEmbed ...
3
votes
1answer
667 views

Loading Javascript Only When Specific Content Existing in a Post?

I'm trying to add Javascript for my "PrettyPhoto" plugin to pages only when their content contains rel='prettyPhoto'. This looks very simple to me but all solutions I've found on the internet doesn't ...
1
vote
3answers
615 views

How to Add Javascript Only When a Function Exists?

I have a few function. For both of them need javascript code. I need to add javascript code in header only when function is active. At this time I have all my javascript code in header for all my ...
1
vote
1answer
604 views

Can I create a loop with multiple post types and specify different $args for each post type?

I'd like to create a custom loop that includes all Post types: Post and Video. Then I'd like to specify to show all posts of the post type Video, but only show posts that are in the category ...
0
votes
1answer
156 views

How can I detect hierarchal relationships beyond children (grandchild, great-grandchild, etc)?

Often times, a custom theme for Wordpress will require a dynamic content that reflects a relationship to a top level page of a site. Is there a Conditional Tag that will check if the current page is ...