Skip to main content

Questions tagged [conditional-content]

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

conditional menu with custom fields

currently i have, as custom field on buddypress registration, the option to register as User Type A or User Type B. I want to show a menu for user type a and another menu for user type b. How can i ...
B Project's user avatar
0 votes
1 answer
58 views

Create a page from different content blocks

I would like some advice on how to set up a job. I have a set of "content blocks" I give an example: Block 1 | Block 2 | Block 3 | Block 4 | Block 5 The goal is to make in a fairly fast way ...
bastiag5's user avatar
0 votes
1 answer
38 views

Selective styles and scripts inclusion

I'd like to know if is there any method that allows to include scripts on specific pages/templates depending if those page have a specific get_template_part inside. Example: I have more than one page ...
MKay's user avatar
  • 179
0 votes
1 answer
624 views

Enqueue Stylesheet on the front end and in the block editor Conditionally

How would you include a stylesheet in both the block-editor and on the front-end if the page meets certain criteria? In this case I want to include a stylesheet called homepage.css if the page is the ...
Walrus's user avatar
  • 131
0 votes
2 answers
59 views

How to conditionally display an ACF custom textarea contents only to those users chosen from an ACF User field

How to conditionally display an ACF custom textarea contents only to those users chosen from an ACF User field. I have an ACF User field (allowed_users)that author's can multiple select when they ...
Pete's user avatar
  • 1,048
2 votes
0 answers
51 views

How to only render `PluginDocumentSettingPanel` if there are children

I want to use the PluginDocumentSettingPanel similar to how the InspectorControls component works, where I can add my own controls from different parts of the application. But if there aren't any ...
Corey's user avatar
  • 182
0 votes
1 answer
28 views

How to tie two conditions to one statement

I need to tye to conditions to the same statement. Both conditions have to be true Here is the conditions (the code is working) if (has_tag( 'aria condizionata', $post ) ) { $ac_inc = '<div class=&...
Andrea Sacconi's user avatar
1 vote
2 answers
145 views

Content Restriction but allow public REST API

My Question, is it possible to restrict the content from a post (shwo e.g. teaser/excerpt only) but still let access the content fully by the REST Api interface? My scenario is that i would like to ...
RestAPPDev's user avatar
1 vote
1 answer
68 views

Conditional concerning a selected tag not working

I'm trying to print some content in all the posts under a certain author only if a specific tag (default wp taxonomy) is set the tag is "animali permessi" here is the code $posttags = '...
Andrea Sacconi's user avatar
0 votes
2 answers
42 views

Link from page to category posts

I'm stuck and grateful for any help I have a number of categories and a site 'about' page I also have 'about pages' for each of the categories (sort of subject intro pages) The about pages are all in ...
PLinB's user avatar
  • 3
0 votes
1 answer
274 views

Display a block conditionally based on user input button

I am looking to put 2 donation forms on a page using a shortcode (or block) and I want them displayed based on currency selected by user,So for instance a user comes onto the page he will see 2 ...
netzih's user avatar
  • 101
0 votes
0 answers
320 views

Dynamic Buttons According to URL parameter

I am working on a WordPress Site. I just want to add a button on a page and track its behavior. My main question is when I create a campaign URL, I just want to change button behavior according to the ...
YMG's user avatar
  • 111
0 votes
1 answer
90 views

Getting false for is_home() on Posts page

I've made a child theme of Twenty Twenty theme and want to display the posts/ category archive pages in flexbox grid. However, none of the conditional tags I'm hoping to check outside the loop (...
MikeiLL's user avatar
  • 579
1 vote
2 answers
2k views

check if post is set to "password protected"

I'm trying to find a way to show different content if a post is set to "password protected", once the user entered the correct password. I want to show the price of an art piece only on ...
user2882154's user avatar
0 votes
0 answers
145 views

wp_enqueue_script JS code runs too late (after user begins interacting)

The issue is that we need to replace some HTML based on the user's user agent string but by the time the JS code is loaded and runs, the user is already interacting with the page. Is there some way to ...
Slbox's user avatar
  • 109
0 votes
1 answer
176 views

Conditionally run function based on custom meta value?

I’m looking for a way to conditionally display an image within certain Woocommerce hooks that I choose based on whether a value is true within a custom meta field for the products on my site. For ...
positivecharge's user avatar
0 votes
1 answer
22 views

Target a page with query

I have those 2 pages that are created from a plugin (see the plugin https://zombify.px-lab.com/frontend-page/, just login and choose a post type, check the url): https://www.domain.com/post-create-...
Honoluluman's user avatar
0 votes
2 answers
253 views

Custom wp_query inside a conditional stament inside a template part doesn't work: why?

this is a bit messy and I cannot understand why my approach isn't working or what my error is. I'm using a template part to include a custom wp_query into my theme. I'd like to have two different ...
Gatto Nero's user avatar
2 votes
1 answer
141 views

How to do conditional publishing?

I am trying to write a plugin that will stop a user from publishing (or updating) a post if a given condition is not met, for example, if the title of the post is already being used in a different ...
David Valenzuela's user avatar
0 votes
1 answer
56 views

Loading a stylesheet conditionally & verifying CSS

There are several posts similar to this problem, but I need to still ask for help... The need is to change the column heading for posts if the Archived Posts page is selected in the menu (normally '...
rixter's user avatar
  • 101
0 votes
1 answer
229 views

How do I make content only load on desktop? [duplicate]

In order to improve the performance on mobile, I want to load some of the content on one of my sites only on desktop (this is content that is also not clicked on mobile). If I simply hide it via CSS, ...
TheKidsWantDjent's user avatar
0 votes
1 answer
2k 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 ...
silviubogan's user avatar
1 vote
0 answers
377 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 ...
Aleš Sýkora's user avatar
0 votes
2 answers
555 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 ...
Carol's user avatar
  • 1
0 votes
1 answer
2k 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 ...
Vincent's user avatar
  • 101
0 votes
1 answer
38 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 ...
Vincenzo Piromalli's user avatar
0 votes
2 answers
746 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 &...
Mohit Singh's user avatar
1 vote
1 answer
148 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 ...
Carey Robinson's user avatar
0 votes
0 answers
55 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 ...
Juniper Scott's user avatar
0 votes
1 answer
19 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 ...
thatrubynoob's user avatar
0 votes
1 answer
22 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-...
Addy's user avatar
  • 1
0 votes
2 answers
68 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 ...
Scott's user avatar
  • 1
0 votes
1 answer
705 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: ...
aubsauce's user avatar
0 votes
1 answer
152 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-...
S2LF's user avatar
  • 21
0 votes
1 answer
637 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 ...
Sergi's user avatar
  • 260
0 votes
1 answer
90 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 = [...
ottosatto's user avatar
  • 101
0 votes
1 answer
435 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 ...
aliselvi's user avatar
0 votes
1 answer
2k 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 ...
hedgehogsweater's user avatar
0 votes
1 answer
254 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 ...
Asbjoedt's user avatar
0 votes
1 answer
4k 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</...
hessam hosseinipour's user avatar
0 votes
2 answers
102 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 ...
Curtis B's user avatar
0 votes
1 answer
625 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 ...
Bram's user avatar
  • 276
1 vote
2 answers
836 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(...
Jon's user avatar
  • 325
1 vote
0 answers
15 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 ...
Amir's user avatar
  • 11
0 votes
2 answers
46 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.
Pete's user avatar
  • 1,048
0 votes
1 answer
41 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
Pete's user avatar
  • 1,048
1 vote
0 answers
63 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 ...
Brad Rhoads's user avatar
1 vote
1 answer
51 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 ...
Abu Nooh's user avatar
  • 131
1 vote
2 answers
10k 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, $...
Out of Orbit's user avatar
1 vote
1 answer
70 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 ...
RadianDynamics's user avatar

1
2 3 4 5 6