Title: Getting $attributes data in theme
Last modified: September 8, 2023

---

# Getting $attributes data in theme

 *  Resolved [KS](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/getting-attributes-data-in-theme/)
 * 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:
 *     ```wp-block-code
       <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](https://wordpress.org/support/users/karl19/)
 * (@karl19)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/getting-attributes-data-in-theme/#post-17046742)
 * 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:
 *     ```wp-block-code
       <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.

 * ![](https://ps.w.org/lazy-blocks/assets/icon-256x256.png?rev=2584676)
 * [Custom Block Builder - Lazy Blocks](https://wordpress.org/plugins/lazy-blocks/)
 * [Support Threads](https://wordpress.org/support/plugin/lazy-blocks/)
 * [Active Topics](https://wordpress.org/support/plugin/lazy-blocks/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/lazy-blocks/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/lazy-blocks/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [KS](https://wordpress.org/support/users/karl19/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/getting-attributes-data-in-theme/#post-17046742)
 * Status: resolved