Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

The tag has no usage guidance.

0
votes
1answer
20 views

ACF: Filter Conditional Logic Sub Fields Based on Parent

I am trying to create a search that filters posts by country and state/region/province. I have created some conditional logic sub fields based on country and now I am trying to figure out how to ...
1
vote
0answers
21 views

How To Conditionally Include A Short Code Depending On The HTTP_REFERER [closed]

I want to show a form at the end of my purchase-confirmation page only in the case where the previous page / HTTP_REFERER is the checkout page. I've tried lots of different ideas. For example, I was ...
0
votes
0answers
18 views

“Current page” class to apply only if “is category link”

I have a menu with any link that point to a category page. It's basically a filter but what I want to do is generate a class="current_page_item" to any tag anytime I'm in the current category page. ...
1
vote
1answer
24 views

Change content of page in child theme using plugin

I have a child theme in which I created a page template. I am able to show different content based on time of day by writing some PHP inside the actual page e.g. if ( $time < '10:00'){ echo "The ...
0
votes
0answers
25 views

Content to display only on approval

I'm trying to make my site cookies compliant with GDPR but I have embedded iframes from a third party site in the content of my posts that is embedding cookies when they load. I would like to have ...
0
votes
1answer
62 views

Conditionally hide or show woocommerce product variation in fontend by custom field

I have added a custom field (checkbox) to product variations with the following code: /** * Create new fields for variations * */ function variation_settings_fields( $loop, $variation_data, $...
1
vote
1answer
31 views

Duplicating Table of Contents for Paginated Post

I have a technical blog with very long posts. I'm using pagination (via <!--nextpage-->) to separate the content into multiple pages. I manually add an html table of contents (TOC) on the top of ...
0
votes
2answers
16 views

Show code only on WooCommerce Pages

Does anyone know how to put code into your theme that will only shop up on WooCommerce pages? I want to add a cart link but don't need it to shop up on the rest of the site. Thanks!
1
vote
1answer
30 views

Change Woocommerce order button page on particular page

I currently have this in my functions.php to change the default order button text in woocommerce. add_filter( 'woocommerce_order_button_text', 'woo_custom_order_button_text' ); function ...
0
votes
1answer
32 views

Dynamic Content w/ geolocation in WP?

I'm really just looking for ideas and guidance while foraging for memory processing in the WordPress CMS Divi Structure. My company is in need of a good ContentPlaceholder solution. True to the MVC ...
0
votes
0answers
32 views

Conditional Fields depending on checkboxes

I'm currently trying the following (simplified objects): I have a bunch of "objects", which are cities. Each city has a relating country (even though I'm not sure how to implement this relation, yet),...
0
votes
1answer
57 views

Conditional: IF current user has NOT commented on current post (not including post author)

I'm trying to find a way to have a conditional snippet in single.php where //do something happens if the current user has not commented on the current post. I'm hopeless at coding but I'm guessing I ...
0
votes
1answer
20 views

Display post if a specific tag is present

I want to display a particular message when a post has a specific tag on the article. I've done this, however the 'Hello' text is being shown no matter if the post has the tag 'test' or not. <?...
1
vote
1answer
38 views

Conditional based on number of specific custom taxonomy terms in archive.php

I struggling to find a way to count and conditionally apply // do stuff based upon the number of terms of a specific taxonomy(ABC) in archive.php... All I have is this below but it counts all the ...
0
votes
0answers
20 views

Add filter conditionally to a page

I am using a filter to change a label on a particular page and set the rest the same. add_filter( 'woocommerce_product_single_add_to_cart_text', 'themeprefix_cart_button_text' ); //Add New Pay ...
1
vote
2answers
424 views

If post author role is X

Simplifying how I currently show featured posts, when a post is submitted by a full member, a post_meta value is added to the post which is then styled differently. But Id like to do it based on the ...
0
votes
1answer
15 views

Show this code if user has previously left a comment

Below is my code which is inserted into the comment template, It should show the comment form, if the user has never posted a comment on a particular post. Or if they have posted a comment on this ...
0
votes
1answer
348 views

FacetWP - conditionally display facet labels

The following code generates a label for a facet (see sidebar). I would like to add a conditional statement that prevents the label generation is the facet if empty. $(document).on('facetwp-loaded', ...
0
votes
1answer
574 views

Changing select options based on previous select with PHP & AJAX

I looked at some answers here on SO and googled a bit... But couldn't make this work. I have 0 experience with Ajax and I'm new to PHP. What I need is to change the options of the other selects based ...
0
votes
0answers
44 views

jQuery Conditional functions while pre-populating ACF input fields

I have a pretty complex form in WordPress using Advanced Custom Fields. Unfortunately, ACF doesn't allow dynamic field population as such so I'm using jQuery to do so. This is the code I'm using for ...
0
votes
1answer
76 views

How to know if the most recent article

I would like to know how to know if the next article is the most recent ? And if is not the most recent, dont' show the content (The right arrow and "Article suivant") please, Here is my current code ...
0
votes
3answers
41 views

Restrict content piece by role - Protection message in content?

I use below function (Nothing here is protection message): function show_user_content($atts,$content = null){ global $post; if (current_user_can('subscriber')){ return $content; } ...
0
votes
2answers
84 views

Using Switch Statement to Change Image According to Last Digit of Topic ID

I am trying to build a function, which gives out different image-urls, according to the last digit of bbp_get_topic_id(). This is, what i've got so far: function bg_image_topic_titlearea() { $...
1
vote
1answer
50 views

Redirect to a different page through registration, depending on page

I have the following code in my function.php: add_filter('foo_registration_redirect', 'my_foo_registration_redirect', 12); function my_foo_registration_redirect( $redirect_to) { if (is_page(...
1
vote
1answer
521 views

BuddyPress User Profile Menu

I need to show BuddyPress menu item just specific roles and hide all other users. I have 2 user roles like subscriber and author. For example; I want to show my friends only to the authors and to me. ...
0
votes
1answer
92 views

pull data from wordpress database

In WordPress, i am using a plugin named "Business directory" that plugin created a table, name "wp_wpbdp_listing_fees". and there have some column. column name "listing_id" has all "custom post type" ...
0
votes
2answers
52 views

Conditional: IF current author's custom post has a post thumbnail

I'm trying to make a conditional if the current author has uploaded a featured image in a custom post, but it ain't workin' ... <?php if ( 1 == count_user_posts( get_current_user_id(), "...
1
vote
1answer
669 views

How do I toggle pagination on/off in search results and category listings via a link?

On this website, the user wants to be able to switch off pagination, so as to be able to send the entire results of a search or category query to print as one big document. Seems obvious, so I was ...
0
votes
1answer
679 views

Conditional redirect on login using referring URL

My clients site has a form only viewable to people that have a specific user role (custom). They are sending out a link to an RSVP page but in order to view that page the visitor must be registered ...
3
votes
1answer
260 views

Show/hide Widgets in Dashboard Based on Current Advanced Custom Fields Option

So, in an effort to move my new project forward, I'm looking for a way to register and de-register widget areas depending on which header file I load via ACF Pro in the Options page. A bit of info ...
0
votes
2answers
42 views

Which is the better way to write a conditional statement? [closed]

Which is better... <?php if (is_page()): ?> <?php else: ?> <?php endif; ?> or <?php if (is_page()) { ?> <?php } else { ?> <?php } ?>
0
votes
1answer
23 views

Insert a conditional in the middle of a function to give it 2 different outcomes

I have this function that displays a comma separated list of custom taxonomy terms. <?php $product_terms = get_the_terms( get_the_ID(), 'XYZ' ); // Make sure we have terms and also check for ...
0
votes
1answer
44 views

What is the best way to disable my WP website if the user has adblocker on? [closed]

What is the best way to disable my WP website if the user has adblocker on? But at the same time let the user know why and what they need to do.
0
votes
1answer
60 views

Conditional/Check: IF author has no First Name THEN

I'm looking to find a way to check if the author has included their first name (at registration) and if they haven't then do something... I have no idea where to start, or finish, but I assume it ...
0
votes
1answer
458 views

Multidimensional Array

I have an array in my wordpress template where i want to then target a specific status of the logged in user. Below is what i currently have with the $args containing a status with all the status ...
0
votes
1answer
39 views

How can I use 'edit_form_after_title' conditionally?

I'm using it to add a message to posts/pages/cpts, but it's also appearing on one screen of a plugin - so I need to remove it. I have the screenID, but my knowledge-lacking efforts to add a ...
0
votes
1answer
256 views

Is_front_page inside header.php is always returning true

I have a page that I designated as my front page using the reading portion of settings in the dashboard. When I place a script inside of an if statement using is_front_page in functions.php, it only ...
4
votes
2answers
535 views

Can a conditional statement apply to part of a slug?

Is there a way (and if so, 'how?') to apply a conditional to a page/post for which the slug contains a specific word. In the case of the Codex example of: is_single( 'beef-stew' ) The condition ...
0
votes
2answers
254 views

Conditional does not work with add_filter

I want the conditional to be applied and that it is only displayed on pages, but it does not work, what is wrong? function luc_add_cutom_fields_to_content( $content ) { $custom_fields = ...
0
votes
1answer
21 views

award points to a user each time they update their cpt post

I'm trying to find a way to award a single point to a user each time they update a specific cpt post they have published. The points would need to cumulate. Based on this value, i'd then like to have ...
0
votes
2answers
964 views

Advanced Custom Fields - display label and value only if value entered

i currently have the following: <?php $field_name = "text_field"; $field = get_field_object($field_name); <table> <tbody> if( isset($field['value'] ): ?> <...
0
votes
3answers
146 views

hide/show a div in wordpress

How can I make my <div id='banner'> visible only in index.php and hide it on other pages like single.php in WordPress? My div id='banner' is located in my header and the header is displayed on ...
-1
votes
2answers
35 views

How do I reformat this to add php inside php?

I currently use this conditional code... <?php if ( $paged < 2 ) echo 'some text'; else echo 'some other text'; ?> I need to add some more php between the 'if' and 'else'... <p>Text.....
0
votes
1answer
44 views

Multiple domains, Single database, 1 Parent/Master with all content, other domains/slaves with filtered content (based on “location” variable)

Sorry if the title of this is not clear. Here's my scenario. I want to create multiple sites (will use 3 as example) with the following content filtering. www.main.com - serves all content www.usa....
2
votes
1answer
83 views

Conditions for Users and Visitors

I've got a domain that is under development and have created a plugin that uses wp_die() in a function I wrote. It must be checked against user auth which is conflicting with my plugin because init ...
-4
votes
2answers
37 views

Not able to see the error [closed]

My website receives this error when going to the home page: Parse error: syntax error, unexpected 'endif' (T_ENDIF) in /home/wha2wearco/wha2wear.com/wp-content/themes/pro-blogg/index.php on line 63 ...
0
votes
1answer
60 views

Home Page Template - Specific Category

I cannot find a specific solution to my situation. I'm sure this is an easy one though. I have my homepage set to display posts. How can I narrow the posts to a single category? I've looked elsewhere ...
0
votes
1answer
101 views

Conditional statement: if is_category, append at the end of page

I'm really new to code, so forgive me if the question seems dull. I have set up a very simple WP site its only purpose is to collect content from authors to then export some xml file in order to ...
0
votes
1answer
104 views

Condition within single.php to send an email to the post author

I have this piece of code (below) that checks if the post was modified within the past 7 days. I'd like another piece of code that I can insert where "Needs Updating" is that will send a basic email ...
0
votes
1answer
138 views

Conditional featured image with youtube thumbnail

Basically what I am trying to do here is: Display the youtube thumbnail. If no youtube thumbnail -> Display the Featured image for the post. If no featured image -> Display the fallback image. ...