Articles of conditional content

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 embed my map tag only on my single posts categorized as “listings” But, the embedded tag is also showing within the index of posts (thumb, title, meta, excerpt) and I need to remove […]

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 function and newermind which one of them is active. I tried to make this code but […]

Proper syntax for simple conditional bloginfo language

I need to do something like this: <?php $bloginfo = get_bloginfo( ‘language’ ); if($bloginfo->en-US){ the_time(‘jS F Y’); }else{ the_time(‘d/m/Y’); }; ?> I cant find the proper way to wrap en-US. Any ideas? Thank you in advance, people.

Check to see if specific loop has less than certain amount of posts

I’m looking for a way to check how many posts are returned by a specific loop. So if I have a loop like this.. <?php $featured_post_id = get_the_ID(); global $post; $args = array(‘cat’ => ‘9’, ‘posts_per_page’ => 5, ‘post__not_in’ => array($featured_post_id) ); $my_query = new WP_Query($args); if ( $my_query->have_posts() ) : while ( $my_query->have_posts() ) […]

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. Is there a better way? I’m using Twenty Eleven as a parent theme.

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. example code here: <?php get_header(); ?> <div id=”content” class=”narrowcolumn” role=”main”> <?php if (have_posts()) : while (have_posts()) : the_post(); […]

Conditionally load child themes

I am wondering how to conditionally load child themes? I have a site that is going to change with the seasons. The underlying architecture will remain the same, just different styles and a few minor changes. It seems that child themes is my best bet for this, vs using a bunch of conditional statements within […]

Query posts by content lenght

I am using the code below to pull a random post of my site every 6 hour. if ( false === ( $social_trans_post_id = get_transient( ‘$social_trans_post_id’ ) ) ) { $args = array(‘numberposts’ => 1, ‘orderby’ => ‘rand’); $social_trans = get_posts($args); set_transient(‘$social_trans_post_id’, $social_trans[0]->ID, (60*60*6)); } else { $args = array(‘post__in’ => array($social_trans_post_id)); $social_trans = get_posts($args); […]

Conditionally load CSS/JS/PHP in wp-admin if using a mobile device

I’m looking for a way to conditionally load different scripts if the user is accessing the admin area from a mobile device. In my case I’m looking to restrict the user to just be able to make new posts, so if you log in to the admin area from a mobile device you’re redirected to […]

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 serves as meta information for all my reviews. The problem is when I try to create a post that has the category […]