Skip to content
Advertisement

ACF wordpress Modulo variable

I have some code. Trying to add ACF filed(number) instead static number

JavaScript

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 I think my code will replase post to ad.

Here is full code

JavaScript

So how to resolve ths question?

Advertisement

Answer

JavaScript

the_field displays the value directly and does not have a return value – so you assigned “nothing” to $fff here.

You want to use get_field – that one returns the value.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement