I have some code. Trying to add ACF filed(number) instead static number So when I save this I have error like Fatal error: Uncaught DivisionByZeroError: Modulo by zero When I change <?php $fff = the_field(‘show_ad_every_x_posts’, ‘option’); ?> to <?php $fff = 7; ?> It works fine! The problem is that Im trying to display ADs after every X post. But
Tag: advanced-custom-fields
Displaying a dropdown menu of custom post titles with ACF (Advanced Custom Fields) in WordPress
I would like to display a list of custom post titles with the help of Advanced Custom Fields. First off, I have created a custom post type. Then I have created a few “posts” inside this custom post type ie. Room 01, Room 02, etc. Next, I have created a new Custom Field for each room and set the Location
output the_field of related posts with ACF Relationship
and first off all, thanks for help. I have to following code to display related posts from one custom post type to another with ACF Relationships. what i want to know, is it possible and how can i …
Editing this Snippet to Run One Time Only
We have thousands of custom posts where we need to update the_excerpt using this PHP snippet (which works great when a single post is saved). Is there a way to tweak this code so that we can run it one time (like when we load a page) and then delete it? We’re trying to update each post’s excerpt based on
foogallery php shortcode with ID taken from AFC custom field variable does no display
I have ACF custom field in posts with the gallery ID. The custom field is stored in wp_postmeta table. I am trying to execute shortcode on post page with the gallery id assigned to this post. my code: returns “The gallery was not found!” How to execute the shortcode ont the post page with the ACF value for this post?
Check if str_replace Should Execute First to Avoid Duplicate Strings
Each time we save our ACF form, this snippet adds additional tags around the registered trademark symbol. Our goal is for it to do it just once, so we need to check for the tags first but don’t know how, as we’re quite new to PHP. Answer You should check first if string contains and if it does just don’t
Add custom “Add to cart” button based on ACF field to WooCommerce single product page
I want to add an additionall custom “Add to cart button” on the single product page conditionally using this code: This variable is field from ACF $mamut = get_field(‘mamut’); However when I put this code into my functions.php file, the single product page crash I am using theme Twenty nineteen and Elementor Pro. I’ve tried to remove actions and then
php $image = get_field( ‘image’ ) // if // else
I need an inquiry if there is no image that an alternative image is used. the crazy thing is that it works on four out of 18 images. I think I have an error in the “else query” somewhere. Because if I swap the defalut image with the actual product image, then it works .. but of course that is
How to implement photoswipe into wordpress custom theme?
I’m trying to implement photoswipe into my site but I’m not sure how to go about it for a wordpress site.. I’m using acf repeater to display all images in a grid. I’d like to display the photoswipe …
Add custom field inside a do_shortcode
I’m trying to add a contact form into a page template with contact form 7. However, I want the destination email to come in from a custom field I have created. The code that pulls the custom field …