Questions tagged [conditional-content]
The conditional-content tag has no usage guidance.
270
questions
0
votes
0answers
14 views
Conditional widget for a listing archive page
I am building a listing website (using ListingPro theme)
Inside the Listing Archive page I added some advertising widgets and I need to add conditions to it so that different content is displayed ...
0
votes
1answer
58 views
How to check if the current page is at a specified path in the URL?
I have a page marked as the Posts page that lists most recent blog posts.
It is at path /blog.
I want to know when the user is on this page so that I can display a list of categories of blog posts at ...
0
votes
0answers
13 views
Wordpress comments.php conditional
I am new and probably dangerous at editing php. First time posting a question here, don't know if this is too much to ask. I understand if so.
I have thrown together a custom child theme comments.php ...
1
vote
0answers
22 views
Cluster WooCommerce products in each Category Archive by Tags assigned to products
Hello WordPress specialists. I am building my dream shop and I prepared a structure which I can not build now. Can you help me think about it?
I prepared a product_cat categories which are based on ...
0
votes
0answers
21 views
More Elegant Loading #container (like google chrome)
I have a piece of code to display a simple loading by clicking for example on an action (ajax facet search in my case)
so far it does the job.
/!\
Please don't be confused, read and look at the ...
0
votes
2answers
21 views
How to hide a menu from public, but share content with a private link [closed]
I would like to create a menu or menu item that can only be seen with a private link. So the menu would house various pages, but the content can only be seen with a link that is shared. I have ...
0
votes
1answer
213 views
Conditional Fields for Contact Form 7 not working and displaying [/group] in output
I'm trying to get Conditional Fields for Contact Form 7 up and running in WordPress. I'm using Contact Form 7 version 5.1.3 and Contact Form 7 Conditional Fields version 1.9.14.
I'm trying to follow ...
0
votes
0answers
16 views
How to serve user specific content?
Does Wordpress allow to serve different content to different users?
For example, a site similar to Nest.com, where the site serves global content to everyone, but if a user logs in, then they can see ...
0
votes
1answer
13 views
How can i conditionally load taxonomy-{taxonomy}.php template php files through functions.php
I have a movie review site, i would like to conditionally load the taxonomies of actors and directors only if a option of my theme is active.
At the moment in the root theme folder I have these 2 ...
0
votes
0answers
14 views
Give access to different Gutenberg content based on password/code
I'm trying to have one page on which there is a password field. Based on the password that is filled in, show different content.
if password is "123"
show Gutenberg groupId 1
else if ...
0
votes
2answers
89 views
Conditional formatting on data fetched from MYSQL
I'm not an expert in PHP and I'm trying to apply conditional formatting on data fetched from wpdb. To be fair, I'm trying to create shortcode for this. My motto is to fetch values for $previous_marks &...
1
vote
1answer
23 views
Prevent update of custom user profile meta field on the front end after 1st entry
I have an e-learning website that issues an official certificate of completion when a students complete their training course. The user profile name on the account can be used as the student name when ...
0
votes
0answers
28 views
Find and print first <li> entry from Wordpress post in custom excerpt?
I want to create a custom excerpt for an education website. It has posts that contains and listing. I want to print the first child of ul and a first child of ol tag from the post.
Currently, I ...
0
votes
1answer
17 views
A little stumped - first WordPress theme
I am going through an online Udemy course alongside it I'm building my own little website.
The website has 4 pages 1 of them a front page that I've created front-page.php and the rest of the pages ...
0
votes
1answer
19 views
I'm trying to create an if statement that will only display my button link for tickets if its under 'admission-event'… what is wrong with my code?
<!-- column links -->
<div class="col-md-3 offset-md-2 links">
<?php if ( is_category( 'admission-event' ) ) { ?>
<a href="https://www.eventbrite.com/d/ut--salt-...
0
votes
2answers
34 views
Adding if statement
I'm pretty new to PHP however have managed to put together a site I'm happy with.
Once small issue I am having is that I would like to add content for users with specific roles, this means adding an ...
0
votes
1answer
206 views
Can I set up a hover animation in CSS depending on a PHP conditional?
I created a 'Light' theme and 'Dark' theme in the WP dashboard (via Advanced Custom Fields) that will determine how a series of buttons will look, depending on which theme is selected:
...
0
votes
1answer
42 views
Use modulo condition in ACF repeater Field
I want to make a modulo condition in my ACF Repeater field.
In a while loop, I want my code different if $j is odd or even.
My code:
<div class="container grow mt-5">
<h1 class="text-...
0
votes
1answer
119 views
Adding a template part as part of a shortcode
I am using "Ultimate Member" plugin to allow users to register because I want some content to be restricted for not signed-in users. According to their documentation, there are a few shortcodes for ...
0
votes
1answer
63 views
How can I check the rewrite slug of current post type listing page
Supposed I have these urls: http://my-domain.tld/projects-listing-cpt and http://my-domain.tld/musics-listing-cpt.
The custom post types was setted this way:
Projects:
Text Domain: projets
$args = [...
0
votes
1answer
166 views
WP conditional site logo and header block
i have a customer who had 3 different sites and they wanted to bring all 3 sites under one umbrella site. however, each of the companies have different logos. when i define a logo for the site, it ...
0
votes
1answer
573 views
Change Login or Logout text based on status
I'm trying to display text in a button in the header that says "LOG IN" or "LOG OUT" depending on the visitor's status. The button calls a slider action, so I just need to change the text displayed on ...
0
votes
1answer
51 views
How to make widget appear conditionally
I hope you can help.
I have two pieces of code that I do not know how to pair. I want my widget to only appear on posts and furthermore only if one specific category is picked. Whenever I try to put ...
0
votes
1answer
981 views
choose selected for select option with condition [closed]
I have a select option like this
<select name="select1">
<option value="value1">hots</option>
<option value="value2">popular</...
0
votes
2answers
43 views
Modify wp-login.php Labels Conditionally Based On Referring URL
I apologize if this is an easily answered question - I've been looking for a while and can't quite get my head around it.
I would like to modify the first label for the wp-login.php page based on the ...
0
votes
1answer
283 views
Shortcode to Gutenberg-block: additional text on front-end and conditional display
I'm working to translate a custom shortcode to a Gutenberg-block but am stuck on two issues. This post first treats the current situation, the next heading shows the problems I'm running into in ...
1
vote
2answers
487 views
Display Footer Shortcode Different for Logged In Users
I have a shortcode that displays a block of content. Is there a way I can display different HTML depending on if the user is logged in or not? Below is what I have so far.
function footer_shortcode(...
1
vote
0answers
11 views
Conditional Tags Based on Previously Viewed Posts
I was looking at the Conditional Tags Archive and was wondering if it's possible to show a widget depending on different posts / pages a visitor has previously viewed.
For example, if I had a car ...
0
votes
2answers
40 views
Conditional: IF post creation date is in the first half OR last half of the year [closed]
I'm trying to find a way how to have a simple conditional whereby I can echo something depending on whether the post date is in the first half or last half of the post date year.
0
votes
1answer
20 views
Conditional IF current cat is the smallest/last/end child cat THEN
I'm trying to find a way to check if the current category (archive.php) is the lowest/end child cat in a hierarchical structure.
Something like
IF current cat is smallest child
THEN do this
1
vote
0answers
42 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 ...
1
vote
1answer
28 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 ...
1
vote
1answer
6k 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
51 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
57 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
110 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
169 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
1answer
52 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
168 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
81 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
122 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
119 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 ...
3
votes
2answers
2k 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
29 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
3answers
2k 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
3k 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
1answer
96 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
137 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
747 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
118 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(...