Questions tagged [conditional-content]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
204 views

Create citation and url in post using 3 custom fields with conditions for each field... So close!

I am creating a new baseball blog. When submitting a post, I want Authors to cite their source for a news type of post. I have created a custom meta box with three custom fields: Source title, the ...
0 votes
2 answers
772 views

Conditional sidebar menu

I've created a menu for each section of the site, and I'd like the sidebar to only show the relevant menu to pages in a section, so the 'About' page and its children receive the about menu and the '...
0 votes
2 answers
866 views

Loop to pull content from parent element in custom post type [duplicate]

I created a hierarchical custom post type called "films." It is hierarchical so it can have children elements. I am using a conditional statement in my single-films.php to show different content for ...
  • 209
0 votes
2 answers
720 views

Condition display metabox in case the post is saved

I need to register a metabox in my WordPress custom post, but only in case the post is permanent saved in database. What I mean, when the user click on "Add new" I don't want to display the metabox. ...
0 votes
1 answer
956 views

How do I display something on a particular category page?

How would I display HTML conditional on a particular category page? Say my permalinks to the category pages are http://www.mysite.com/category/awesome-category How would I cast the <?php if ... ?...
  • 113
0 votes
2 answers
147 views

Where do you add code in custom fuctions so it works on a specific page?

Thanks for replying but I still can't get it to work. Is anything wrong with this code? <?php class custom_loop extends thesis_custom_loop { function page() { if(is_page( array('career-work','...
  • 1
11 votes
3 answers
22k 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 Development ...
1 vote
1 answer
235 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 ...
user avatar
4 votes
3 answers
42k 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.
2 votes
1 answer
1k 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 is_category('parent'...
  • 113
0 votes
1 answer
795 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 ...
  • 1,496
0 votes
1 answer
98 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
  • 109
1 vote
1 answer
109 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. ...
  • 1,496
0 votes
2 answers
1k 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 ...
  • 1,015
0 votes
1 answer
588 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 ...
  • 151
0 votes
2 answers
970 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 ...
  • 57
1 vote
2 answers
13k 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 ...
  • 1,666
0 votes
3 answers
354 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
2 votes
1 answer
4k 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
1 answer
355 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 ...
  • 2,772
0 votes
1 answer
194 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 page-sample....
  • 11
0 votes
2 answers
3k 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 ...
  • 1,496
0 votes
1 answer
51 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'); ?>/images/...
0 votes
1 answer
314 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 ...
  • 1
3 votes
2 answers
3k 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, ...
  • 557
0 votes
2 answers
3k 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 ...
  • 177
1 vote
2 answers
585 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
1 answer
536 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
2 answers
272 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 ...
  • 11
1 vote
2 answers
900 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 ...
  • 65
0 votes
1 answer
160 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 ...
  • 319
0 votes
2 answers
445 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 ...
  • 524
1 vote
3 answers
4k 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, plugin ...
0 votes
2 answers
2k 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,163
1 vote
1 answer
3k 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 ...
15 votes
9 answers
42k 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 'Apple' ...
  • 4,991
6 votes
7 answers
8k 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()) { ...
  • 12k
0 votes
2 answers
394 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, ...
  • 319
0 votes
1 answer
2k 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' =...
  • 35
3 votes
1 answer
4k 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 ...
  • 890
1 vote
3 answers
3k 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 ...
  • 12k
0 votes
1 answer
120 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'); wp_enqueue_script('...
  • 630
0 votes
3 answers
3k 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
1 answer
3k 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 ...
  • 339
0 votes
2 answers
513 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 ...
  • 513
1 vote
1 answer
89 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 ...
  • 111
2 votes
2 answers
2k 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';
  • 51
1 vote
2 answers
995 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"; //wp_register_script('...
user avatar
0 votes
1 answer
351 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 : <?...
  • 630
1 vote
1 answer
1k 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 ...
  • 681