Questions tagged [conditional-content]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
21 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 ...
0 votes
2 answers
1k 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() { $...
0 votes
1 answer
920 views

Allow users to only CREATE one single (custom) post

I created a custom post type with taxonomy and now want to allow users (of a specific user group) to post only one single post in a specific category. If the user has already posted a post, he can ...
0 votes
1 answer
14 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 ...
0 votes
1 answer
2k views

How to display content If function exist/condition true?

I've created my custom posts. Data from the same is displayed in let's say single-custom-post.php. Now to clean that file and to remove 100 lines of code, I want to make a new file (let's call it ...
0 votes
1 answer
59 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 ...
0 votes
2 answers
31 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 ...
2 votes
0 answers
18 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 ...
0 votes
1 answer
23 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=&...
1 vote
2 answers
71 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 ...
1 vote
1 answer
64 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 = '...
0 votes
2 answers
1k views

How to display image on condition that a selection has been made

I have a custom post type 'Holidays' and a custom field (created using Advanced Custom Fields) called 'activity_rating'. The activity_rating field is a select dropdown with values 1 to 5. If the ...
0 votes
2 answers
36 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 ...
0 votes
0 answers
17 views

Country selection / country-specific menu

Client makes a malaria drug and it has a few pages that are for specific countries only that will be rather boring for a user to select again and again that they want to see e.g. the information for ...
1 vote
2 answers
753 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 ...
0 votes
1 answer
114 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 ...
0 votes
0 answers
238 views

Conditional display based on ACF checkbox

I have an ACF checkbox sub field in a group field on an options page. It has 4 options, and is set to return “Value”. I am trying to make a series of radio buttons that correspond to these options in ...
35 votes
8 answers
72k 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. ...
15 votes
9 answers
44k views

Why isn't is_page working when I put it in the functions.php file?

I have page called "Apple", the page's ID id 2533. In page.php file I have line: echo $bannerimg And this function in functions.php: if ( is_page( '2533' ) ) { // also tested with 'Apple' ...
0 votes
0 answers
181 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 ...
1 vote
2 answers
9k 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, $...
0 votes
1 answer
77 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 (...
0 votes
0 answers
111 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 ...
0 votes
1 answer
127 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 ...
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-...
0 votes
1 answer
591 views

Give a condition to a wordpress menu item to change its offerid for each landing page I create

So my wordpress site has a one header and one footer with a big CTA as one of the menu items. I want to create a bunch of landing pages but I want to be able to change the offerid in the url for each ...
138 votes
8 answers
386k views

How do test if a post is a custom post type?

I am looking for a way to test if a post is a custom post type. For example, in, say, the sidebar I can put in code like this: if ( is_single() ) { // Code here } I want code testing for only ...
0 votes
2 answers
233 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 ...
2 votes
1 answer
89 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 ...
0 votes
1 answer
48 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 '...
0 votes
1 answer
136 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, ...
1 vote
2 answers
628 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
1 answer
1k 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 ...
1 vote
1 answer
19k 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
0 answers
294 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 ...
84 votes
10 answers
67k views

Enqueue Scripts / Styles when shortcode is present

What is the idea way to register/enqueue scripts and/or styles for use in plugins? I recently made a plugin simple plugin to add the user avatar/gravatar with a shortcode. I have different style ...
0 votes
3 answers
3k 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', ...
-1 votes
1 answer
1k views

A conditional button

I wish to add a button to a page of my site that redirects the user to the signup page, if he is not a registered user, and to another page of the site, let's say Test_Page, if he is a registered user....
1 vote
2 answers
1k views

Personalized message for each unique password-protected page

How do I provide two different personalized messages for two different password-protected pages? I'm able to personalize the default message using the code below, but I'm not sure how to add a second ...
0 votes
2 answers
368 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
1 answer
1k 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
1 answer
31 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
2 answers
632 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 &...
0 votes
1 answer
123 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),...
1 vote
1 answer
137 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
0 answers
51 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
3 answers
21k views

Conditional required fields for Wordpress Contact Form 7

I know this might be considered off topic but I am not sure where else to post this as it also pertains to WordPress as well as the plugin Contact Form 7. If you know where I should post this other ...
0 votes
1 answer
18 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 ...
3 votes
4 answers
14k 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;...
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-...

1
2 3 4 5 6