Beep
Beep

Reputation: 2823

add 1 to field name with perimeters at end Advanced custom fields WordPress

I am using Advanced Custom Fields in WordPress and trying to poop and increment a integer on the end of a field name, this works well until I add a perimeters then it dose not work.

for example

works

 <h3 style="min-height: 150px">test<?php the_field_1('text_', false, false) ?></h3>

works

 <h3 style="min-height: 150px">test<?php the_field('text_' . ($i+1))?></h3>

dos not work (but need working)

<h3 style="min-height: 150px">test<?php the_field('text_' . ($i+1)), false, false) ?></h3>

Dose anyone know how to get around this or if there is a proper way of doing this with perimeters ?

Upvotes: 0

Views: 21

Answers (1)

RiggsFolly
RiggsFolly

Reputation: 94662

<h3 style="min-height: 150px">test<?php the_field('text_' . ($i+1)), false, false) ?></h3>
// to many brackets the error is here, remove this one            ^

In fact to simplify you could use

<h3 style="min-height: 150px">test<?php the_field('text_' . $i+1, false, false) ?></h3>

as the brackets are achieving little or nothing anyway

Upvotes: 2

Related Questions