• Resolved KS

    (@karl19)


    Just started working with this plugin a few days ago, it has some great functionality!

    We built a table of content block, which is essentially a repeater field, containing two text fields (ID and title). We then use the PHP output method like this:

    <ul>
      <?php foreach( $attributes['toc'] as $inner ): ?>
        <li><a href="#<?php echo $inner['toc_id']; ?>"><?php echo $inner['toc_title']; ?></a></li>
      <?php endforeach; ?>
    </ul>

    In the PHP output, we have a bit more code, including JavaScript etc, but simplified it looks like this and works great on the frontend.

    In out theme functions.php we have a function for a mobile footer and I would like to show the block data within this footer function, but can’t figure out how to do it.

    I don’t want the full PHP output from above, as it has a different HTML structure and calls JS files, I essentially just need the $attributes variable and being able to loop through it.

    It feels like it should be quite straight forward, but I’ve been reading through the documentation and forum and can’t figure it out.

Viewing 1 replies (of 1 total)
  • Thread Starter KS

    (@karl19)

    I figured out how to get the data I needed. In the main repeater field, I changed to “save in meta”, then I could use this:

    <ul>
      <?php $repeater = get_lzb_meta( 'toc' );
      foreach ( $repeater as $inner ) { ?>
        <li><a href="#<?php echo $inner['toc_id']; ?>"><?php echo $inner['toc_title']; ?></a></li>
      <?php } ?>
    </ul>
Viewing 1 replies (of 1 total)
  • The topic ‘Getting $attributes data in theme’ is closed to new replies.