I’m puzzled by the behaviour of PHP 7.4.21. Inside a Wordpress page I have this piece of code: the function the_field() is a function of ACF (Advanced Custom Fields) plugin and returns a string with the content the user has set inside the custom field. The strange behviour I’m referring to is that inside the ifs all the blocks of
Tag: advanced-custom-fields
the_field – ACF not working in ‘while’ loop
Main string of code (that doesn’t work): <span class=”price-in-kune”><?php the_field(‘tariff_price_kn’) ?> kn</span> The ways i tried to solve this problem: put insted of the_field(‘tariff_price_kn’) – echo(‘hi’) – the code worked add $post_id -> the_field(‘tariff_price_kn’, $post_id) $currencyKune = get_field(‘tariff_price_kn’); And then echo $currencyKune P.S 3) i don’t know exactly where should i put $currencyKune = get_field(‘tariff_price_kn’), so i put it before
Get parameter of shortcode in Insert PHP Code Snippet plugin using ACF repeater
Everybody hello! I’m sorry for asking such kind easy question, I’m pretty new at this. I have problem with transfering parameter value and echoing it to itself. PHP code snippet on page: [xyz-ips snippet=”Generating-content” paramSet=”1″] Inside ‘generating content’: Right now I need to change condition if($sub_value == 1) to if($sub_value == “PARAMETER VALUE”) Please help, guys! Answer Thank you guys
Getting Post Thumbnail to show for Single Post Obect (WP + ACF)
I am having a hard time getting the Wordpress thumbnail to show up when I am using Advanced Custom Fields Pro Post Object. My goal is to have the user select a single featured post to show up after the 6th post on the blog page. This is my code (which is pretty much directly from ACF documentation): This returns
How do you query a custom post type (CPT) via an ACF relationship field?
Overview I have two CTPs: Range: Which showcases 4 van types Wheels Which showcases all wheels a van can have. In the wheels post type, I have two ACF fields: Image: Which is of type image (an image of the wheel). The name of this field is image Available on: Which is a relationship field where we can select which
Using an ACF text field to display metatag on specific pages. Can’t get the acf field to return correctly in functions.php
I am in the process of implementing ios smart banners on our site, however we only want it to display on selected pages. I have set up an ACF text field, where I have the page IDs as a comma separated string ( eg: 1234, 1235, 1236, 1237 ). In the functions.php file I have created the following function to
ACF & WordPress Media Library
I’ve got an ACF ‘options page’ with a placeholder image within, to fall back to if a client removes the image from the post/page by mistake. And I’m using the following code to handle this situation happening. This works fine once pages or posts are saved. However The issue I have is if the page/post has been previously saved with
How do I get and set Advanced Custom Fields data as a variable in Timber $context to use in a post query?
I want to get and set the value of an ACF field into a variable in my home.php file and then use this as part of a query. So, for example, if a user enters the word ‘event’ in the the field ‘cat_name’ in the CMS, I wanted to get and set this as a variable and then use this
How to display ACF field after the product name on the cart and order reviews in WooCommerce?
I have Advanced Custom Fields setup for post type on WooCommerce Products. So each product has 1 unique custom field. I’m trying to display the custom field after the product name on the cart and the checkout page and order table information. However, running into problems as my code doesn’t display any output. Any advice on how to achieve this
How to Convert Number to always have 2 digits after the decimal?
Quick question: I am trying to always get 2 digits after the money amount I previously had this code: But it only returns me 650 and I want it to return 650.00 I have tried the following with no success: Thanks for any help on this, still a noob at php. Answer You need PHP will coerce the variable to