The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
2answers
21 views

PHP conditional script issue

I'm have the 2 seperate block of codes as shown below and the one below doesn't work except if I cut off the first one. Any ideas what the problem could be? Conditinal script <?php { ?> ...
0
votes
0answers
20 views

Conditional loop based on current page

I'm trying to get the loop below to display only the post with the category that reflects the given condition but it doesn't seem to work. Any Ideas on how this can be achieved? <?php if ...
1
vote
1answer
36 views

One custom loop with condition to check child posts

I have one loop of pages with 999 page ID as a parent (pages from this loop have also another child pages) $args = array( 'post_type' => 'page', 'post_parent' => 999, 'order' => 'ASC', ...
0
votes
1answer
25 views

Conditional statements based on custom meta value in category archives

Here's what I need to do. Insert a short Javascript in the footer using wp_footer. No problem there for single posts, I have this. add_action( 'wp_footer', 'prefix_wpfooter' ); function ...
0
votes
0answers
8 views

Tag, Category and Single Conditionals

We have this sample: This function call Backgrounds in different places in the WP I add it to the <body> <?php function backgrounds(){ global $wp_query; if(is_home() || ...
0
votes
1answer
29 views

Php conditional help needed

I am trying to add conditionals for authorship to show for posts on a specific author id. Would appreciate if someone could give the following a quick look over <?php if is_author ('2') AND ( ...
1
vote
2answers
53 views

What is the correct way to write this conditional statement?

I'd like to remove auto formatting 'wpautop' from specific pages. Here is what I've got, but it doesn't appear to work: if ( is_page ( 'services' ) ) { remove_filter( 'the_content', 'wpautop' ); ...
0
votes
0answers
52 views

How to display only the posts with category that match the current page URL

I'm trying to get the loop below to display only the posts with the name that matches the current page's absolute name. E.G: if the URL of the current page is mysite.com/current, then the post to be ...
1
vote
1answer
48 views

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

Advanced Custom Fields | how to use conditional statements in repeatable group display

Hi there, I'm just getting started with ACF and writing php statements. Although I've been working with them for a little while I'm still building confidence. My aim To display a block of code if a ...
0
votes
1answer
69 views

Help with if else statement for separating content from image attachment

I am currently having some trouble executing the following. I would like to separate the image (wp_get_attachment_image) from the content (get_the_content) by using a conditional statement to display ...
0
votes
1answer
119 views

Get all children page ID's including parent by title

So I am getting all the children ID's as well as the parent ID to show content only for that page and all its sub-pages. This is the following function I created, but was wondering if there is a ...
0
votes
3answers
93 views

Conditionally set post_content in wp_insert_post

Is it possible to conditionally set the post_content in wp_insert_post? Im using a foreach to add multiple pages at once: foreach ($create_pages as $new_page) { $add_pages = array( ...
0
votes
0answers
92 views

Wordpress custom metabox radio values using CMB

thanks for reading. Im using https://github.com/WebDevStudios/Custom-Metaboxes-and-Fields-for-WordPress to create custom metaboxes. I have created a radio metabox that looks like below. ...
0
votes
0answers
45 views

Only ads with pictures in featured slider

I have classified ads wordpress website with jCarouselLite slider on main page. Is there any way to make the featured slider exclude ads that have no image attachments, so the featured slider only ...
0
votes
1answer
39 views

Conditional loading of CSS for my plugin

I'd like to continually load the stylesheet needed by my plugin depending on whether a particular shortcode is present on the post or page. The presence of the shortcode would indicate that the user ...
0
votes
2answers
48 views

How to write this conditional statement?

What is the correct way to write a conditional statement? <?php if is_tag( 'Premium' ){ <a href="<?php the_permalink(); ?>" class="info"> ...
0
votes
1answer
25 views

Display WP Start bar on front page only

I was wondering if someone could help me display the plugin WP Start bar only on my static frontpage. If it helps my static frontpage url is: http://zackarylundquist.westhostsite.com/portfolio/
-2
votes
2answers
163 views

Multisite Conditional (if blog_id?) in a page template?

I have a WordPress network with multiple sites using the same theme. Now I need to edit part of a certain PageTemplate.php to display different things based on the blog id. Example: If blog ID 1, ...
0
votes
0answers
59 views

restrict access to specific urls on a specific period of time

I have a countdown timer plugin which is set do redirect the user to a specific permalink after the time is elapsed. I've added a countdown timer here : mywebsite.com/mypost which is set to 3 days ...
0
votes
0answers
27 views

Using conditionals, maybe from a DB, to register & enqueue files, for varying pages, in functions.php

I wanted to include some javascript and css files on only some of my WordPress pages. To do this, I registered and enqueued the files in my child theme's functions.php file, and used conditionals to ...
0
votes
0answers
76 views

functions.php conditional output for a single plugin

hope I've asked this correctly. Bizarre situation. I have some non-breaking spaces in my titles for typography reasons. They are added automatically where required in place of normal spaces by the ...
0
votes
0answers
21 views

Show some content if the user has done something

I am looking for an easy way to set conditions that the user has to meet before some content will be available for him. I want to make something like a tunnel of pages, for instance, where the user ...
1
vote
1answer
56 views

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 ...
1
vote
0answers
160 views

Conditional Filtering in Contact Form

I need a contact form where I will have ListBoxes ( with states and cities. I want that when the user selects a state in list1, the list2 should only have cities which are inside the selected state. ...
0
votes
2answers
269 views

Dynamic Sidebar Conditional [duplicate]

EDIT Answer was found here: is_active_sidebar() Always Returns False By user: s_ha_dum I'm dynamically creating sidebars and registering them for every top level page: Dynamically Register ...
0
votes
1answer
632 views

conditional statement for custom taxonomy

Struggling to find out how to achieve this, if it is at all possible. The equivalent of is_category but for a custom taxonomy I've set up. The taxonomy category if which being Taxonomy Name with 2 ...
1
vote
1answer
139 views

Search filter triggered & sort by custom post type

I am using a plugin (Relevanssi) and a custom function to sort the search results by custom post types (see below). This is working great. add_filter('relevanssi_hits_filter', ...
0
votes
2answers
26 views

Why might conditionals not work on a page?

<?php if (is_single()) { echo '1'; } elseif ( is_page() ) { echo '2'; } else { echo '3'; } ?> I put this snippet at the top of index.php, which is what I'm using to govern the ...
0
votes
1answer
648 views

The conditional logic only works to show or hide?

I am using the Advanced Custom Fields for custom fields in the User Profile. I use conditional logic to display one of between four fields, each field will be displayed according to a radio field ...
0
votes
1answer
385 views

If custom taxonomy else conditional [closed]

I have a menu that I only want to show on certain pages using the following code: <?php if ( is_front_page() || is_archive() || is_404() ) { } else { if ( function_exists('has_parent') ) { ...
0
votes
1answer
617 views

Creating conditional to display taxonomy term meta

I'm trying to display an extra meta field for taxonomy terms. wever I'm trying to create a conditional, in that, if the meta field is empty, show a default value. here's the code for creating the ...
0
votes
2answers
56 views

Php markup question: php/html within conditional bit

I'm getting very confused trying to get an existing bit of code to work within a conditional if/else bit of code. I can't get the syntax correct. All the echo commas and semi colons (sorry I'm not a ...
0
votes
1answer
608 views

Conditionally remove comments and post meta in functions.php

I'm new to Wordpress and am coming from the point and click world of Joomla! what was easy there now involves some solid php knowledge to replicate in Wordpress ;) I'm try to conditionally remove ...
0
votes
1answer
265 views

Is there a way to password-protect part of a post?

Is there a way to have a page displayed to the public, but have an extra custom field that doesn't display unless a password is entered? I suppose I could do entirely manually without WordPress ...
0
votes
1answer
48 views

How to get type of archive whether it is post or date or category archive?

using function is_archive() we can know whether it is archive page or not. But if it is archive page how can i find whether it is author archive page or category archive or date archive. I have ...
1
vote
1answer
119 views

Add user settings to specific roles

Is it possible to do this? I already know about get current_user_can(), which does not work like I need. I'd like to be able to use an array if there are multiple roles. // Check roles to only add ...
0
votes
1answer
173 views

How to hide <pre> and <table> content from auto-generated excerpts?

Auto-generated excerpts just take the first x characters from the post content and cut that off at a certain point. When there is a table or pre element in that part, the excerpt looks rather useless ...
0
votes
1answer
274 views

How to display conditional-content if wp_nav_menu( $args ) retruns something

I have a sidebar that displays child links of the current page (using this solotuin by http://wordpress.stackexchange.com/a/2809/27414) which works perfectly. If there is child links to be displayed ...
0
votes
2answers
33 views

Checking conditionals

We all know about the default WordPress post types, these being aside, gallery, status, chat and so on. any good theme should support all of them. In the case where a theme does support all of them, ...
1
vote
1answer
76 views

How to not show post_thumbnail from specific category for not logged users

Can you guys help me with some examples so i can sort out the thumb posts from a specific category (EXAMPLE) to not be shown for not logged users, instead to be shown an image which tells them that ...
-2
votes
2answers
87 views

How to set up a echo? [closed]

My problem is that i don't know how to set up a echo I think. I need it to just wrap a if statement correctly around the code below Please Help...Thanks SO much <?php global $post; ...
0
votes
1answer
805 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
200 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
119 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
91 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
219 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
108 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
220 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
71 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() ) ...