skip to Main Content

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’:

<?php if( have_rows('information') ): ?>
   <?php while( have_rows('information') ): the_row(); ?>
      <?php $sub_value = get_sub_field('number'); 
         if($sub_value == 1): ?>
            <div class="d-block d-md-flex d-lg-flex">
               <img src="<?php the_sub_field('image'); ?>">
                  <div>
                     <?php if( have_rows('repeatable_content') ): ?>
                        <?php while( have_rows('repeatable_content') ): the_row(); ?>
                           <p>
                              <?php the_sub_field('text'); ?>
                           </p>
                        <?php endwhile; ?>
                    <?php endif; ?>
                </div>
            </div>
        <?php endif; ?>
    <?php endwhile; ?>
<?php endif; ?>

Right now I need to change condition if($sub_value == 1) to if($sub_value == "PARAMETER VALUE")

Please help, guys!

2

Answers


  1. Chosen as BEST ANSWER

    Thank you guys for helping! The main issue of this problem is that you have to buy premium version of this plugin, your version is working in another plugins :)

    Working plugin's name: Shortcodes Blocks Creator Ultimate


  2. I think that is what you are looking for.Not tested but it should work.

    <?php
      $paramSet = (!isset($atts['paramSet'])) ? $atts['paramSet'] : 'default';
     if (have_rows('information')) : ?>
    <?php while (have_rows('information')) : the_row(); ?>
        <?php $sub_value = get_sub_field('number');
        if ($sub_value == $paramSet) : ?>
            <div class="d-block d-md-flex d-lg-flex">
                <img src="<?php the_sub_field('image'); ?>">
                <div>
                    <?php if (have_rows('repeatable_content')) : ?>
                        <?php while (have_rows('repeatable_content')) : the_row(); ?>
                            <p>
                                <?php the_sub_field('text'); ?>
                            </p>
                        <?php endwhile; ?>
                    <?php endif; ?>
                </div>
            </div>
        <?php endif; ?>
    <?php endwhile; ?>
    

    Read More – https://developer.wordpress.org/reference/functions/shortcode_atts/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search