-1

I have a code which returns gallery number 1 with the set of images.

<?php echo photo_gallery(1); ?>

But I need to change number "1" to number "2", "3" and so on with custom fields in every post using this code

<?php the_field('number'); ?>

inside the first code

I need something like this:

<?php echo photo_gallery(   <?php the_field('number'); ?>   ); ?>

Result:

<?php echo photo_gallery(2); ?>

or

<?php echo photo_gallery(3); ?>
2

2 Answers 2

0

If you really have a custom field number, your code should be the following:

<?php echo photo_gallery( get_the_field( 'number' ) ); ?>
0

if you want to get the post and then after give the number then follow the code like

$cnt=1;
$queryarry=array( 'post_type' => 'post' ,'posts_per_page' => 9);
while ( have_posts() ) : the_post();
  echo photo_gallery($cnt);
  $cnt++;
endwhile;

try this

Not the answer you're looking for? Browse other questions tagged or ask your own question.