The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
896 views

Add class to DIV depending on page loaded

I'm designing a new theme and in my page template a have a section where an image is displayed . I would like this image to change depending on which page is loaded. The section is a DIV like this: ...
0
votes
1answer
222 views

Custom Meta Box If Else Statement

I have created a custom meta box for posts and I need to display said data. I have been using the below method to display the data, But I am in need of a slightly different solution. <a ...
0
votes
2answers
133 views

Subpage Conditional

I am looking for a way to write a condition for a subpage...in other words if we're on the subpage "duck" then do something...if not do something else. I found some code I thought would work, but it ...
0
votes
1answer
99 views

Parse a shortcode differently based on on what it's nested in

Suppose we have two different sets of nested shortcodes, like this: Apple version [wrapper snack="apple"] Today I had a [flavor] snack... [/wrapper] Desired output: My snack was quite HEALTHY ...
1
vote
3answers
243 views

Displaying a widget in sidebar only when no other widgets rendered?

I am working on a custom theme, basically migrating a current sites look and feel into WordPress. Most of everything is based on Pages, and all of these pages should have a left sidebar. Of those ...
0
votes
1answer
111 views

NextGEN Conditional Statement

What I'd like to do is if the NextGEN gallery has more than one page (pagination) execute some code...I got close: <?php $nggpage = get_query_var('nggpage'); if ($nggpage > 1) { ...
0
votes
1answer
254 views

Help with this custom field conditional if no field is set display nothing

I'm using the code below to display an image if the swap_select custom field value is true. If it's no it displays nothing. However when posts are first created no custom field exists. So what would ...
0
votes
2answers
77 views

exclude custom post type from running a function

I have the following code in my functions.php file to display post shortlink in my posts (I prefer not to edit theme files if possible)... function add_post_content($content) { if ( is_single() ) ...
0
votes
1answer
114 views

Only on single post page

I am using this code to show ad below single post but only if it is in specified category. Code is giving right out put but it is also showing up on archive pages. I just want to show on single post ...
0
votes
1answer
210 views

Conditional function for excluding first image from content, not working

I have the following function: function remove_images( $content ) { if( ( is_category() || is_archive() || is_home() ) && has_term( 'MyCat', 'category', $postID ) ) { $postOutput ...
2
votes
1answer
97 views

Performance-wise, is it better to enqueue a (small) script on every page or test to see if it's needed?

I'm using the FitVids.js script to make YouTube video embeds work with a responsive layout. The script is < 3kb, but only about half of my pages actually have YouTube embeds. In terms of total ...
0
votes
1answer
25 views

why is my custom loop failing?

I have a custom post type to get images. I am setting up my theme to display a specific way when it is first installed. For some reason, my code is stopping the bottom half of my page from displaying. ...
-2
votes
1answer
177 views

Weird html output of single_cat_title - is not inside of the html element?

I'm displaying a single "featured" post at the top of the blog index page, and category pages. I'm using this conditional to display the category name of the category page if it is a category page, ...
0
votes
2answers
114 views

Check IF single OR multiple custom data has been entered

I'm building a single template right now for a custom post type. I'm wondering if there is a way to check if either at least one or multiple of the custom values has been entered so I can display the ...
0
votes
3answers
112 views

How do I add a nested conditional within an echo - to use a default image if there isn't one in the post?

I'm trying to add a conditional that will display a default image if the "image" field isn't populated... here's what I'm trying to work with: $args = array( 'posts_per_page' => 3, ...
0
votes
1answer
948 views

Show content after the first and second paragraph

The function below is used to show certain content after the first paragraph. I would like to show 'content X' after the 1st paragraph and 'content Y' after 2nd paragraph. <?php $paragraphAfter= ...
1
vote
2answers
276 views

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 ...
0
votes
1answer
105 views

Conditional for a Single Post That Belongs to a Category?

I have categories like gaming and movies on my website and when a user visits any of these categories the content in the sidebar is displayed depending on the category they are in. So gaming content ...
1
vote
2answers
511 views

Reordering Buddy Press profile navigation [closed]

I am using this code to reorder the positions of the menu items for BuddyPress profile. I am using the xprofile (not sure if that makes a difference). Here is the code that I am trying to use: ...
0
votes
1answer
224 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 ...
2
votes
1answer
215 views

Conditional Ajax inclusion

I have a custom interface that uses 30+ ajax files while running... some files are only used in category.php while othere's are only used in page.php... i include the ajax loader php files in my ...
0
votes
2answers
100 views

How to use “Cases” instead of “IFs” for conditional logic

Recently I've been developing sites for WordPress that are both increasingly complex but also have much higher rates of traffic. I remember when I was learning the ropes from another about PHP, that ...
0
votes
1answer
298 views

Limit page template choice by page title or ID?

I'm developing a multisite and creating my own themes for it. All the themes will feature some standard pre-defined pages eg. homepage, about, blog, contact us etc. Each page will also have a number ...
0
votes
1answer
153 views

Change a url / link if a user is logged in?

I'm working on some themes for a multisite and would like to modify the code below. It relates to a special div that will display an image or logo that users upload. Normally the logo links to the ...
1
vote
2answers
480 views

Add default content to posts in a specific category?

Update / Question clarification: How could you modify the following code from this thread: Force category choice before creating new post? which offers a drop-down menu to choose a category BEFORE ...
0
votes
1answer
122 views

Why is the `if else` not working?

I have this on my header.php. It checks whether the page is on homepage/frontpage, is on category/children of/has the category of "gamenews", or is on category/children of/has the category of ...
0
votes
1answer
50 views

include <p> content within conditional statement?

I have a gallery page wherein there are multiple individual galleries/sub-pages. I handle this function by using- <?php if( is_page( 39 ) ) { echo do_shortcode('[nggallery id=1]'); ...
0
votes
1answer
37 views

Specific coditional usage [closed]

I have some trouble making work a conditional inside a Function. check this out: I'm using this function: function get_spec_1(){ $desc1 = get_post_meta( get_the_ID(), 'eco_mb_tp_1', true!= "" ); ...
2
votes
2answers
4k views

wp enqueue style on specific page templates

I am in the process of a theme, I would like to add landing pages using page-templates. I cannot find anywhere that shows how to enqueue style or js for specific page templates. Any suggestions. Ex. ...
1
vote
2answers
100 views

Determine page content based on page parent

How can I display a gallery shortcode for pages who are children of the page with an ID of 9, and the regular content for pages who aren't? This is what I've tried so far, but it's not working: ...
0
votes
2answers
48 views

Looks like this if condition is not working [closed]

I want a query to be executed IF the following condition is true... but looks like the query is executed anyways. if($post->post_parent = '302'){ // Query goes here } Is this query fine?? I want ...
0
votes
1answer
116 views

If else with shortcodes

I only want one of these shortcodes to display if the custom field value is true. I'm not understanding the logic to do this. So basically, if there is a twitch video and a own3d video I only want the ...
3
votes
2answers
2k views

How to display the_post_thumbnail if a post has one or otherwise display the first image in a post?

I would like to create a condition that checks to see if a post has a thumbail and if it does display it, otherwise display the first image in a post. I tried something like this in my loop.php but ...
0
votes
2answers
1k views

How to conditionally hide author name on Single.php if category is “news”, otherwise if category is something else display author name?

I would like to be able to conditionally hide the author's name on the Single.php if the Category name is equal to "News" and otherwise if the category is something else hide it. How do I go about ...
1
vote
5answers
342 views

meta content on required pages

I need to post extra information on programs pages, so i have decided to use wordpress metabox but its showing on all pages. So is there any condition check so it could put meta box on those sub pages ...
0
votes
1answer
31 views

Template tag for /page/# structure

I'm trying to find a template page (or conditional statement) that will target: http://url.com but not http://url.com/page/2/ home.php and front-page.php seem to target both. The front ...
1
vote
1answer
82 views

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' => ...
5
votes
3answers
1k views

Check if first paragraph is an image, then show custom code right after it?

I would like to add some code in functions.php that does this: If the first paragraph contains an image, show my custom code right AFTER it. For example: <div class="entry-content"> ...
1
vote
2answers
340 views

Plugin Code ONLY on Post Edit Page

I have a wordpress plugin that is interfering with the function of another plugin. But, I believe the interference only occurs on the admin side. I've found the lines within the code that are ...
0
votes
2answers
534 views

Conditionals if tags exist?

I have the following code to display tagged articles with the same name as the page title, but I only want the to appear if the tag exists, otherwise it just says 'Related Articles' with no content. ...
0
votes
1answer
287 views

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 ...
0
votes
1answer
143 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
2answers
452 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
2answers
366 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 ...
0
votes
2answers
234 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
1answer
237 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 ... ...
0
votes
2answers
136 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( ...
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
206 views

How do display simple page for printing product info?

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
5k 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.