WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
[resolved] Getting values from parent page (2 posts)

  1. rikardo85
    Member
    Posted 7 months ago #

    Hello,

    I am trying to get the values from a parent page which is using the repeater functionality.

    I would like to display the values on the child pages and possibly grandchild pages.

    Below is the code I am using to display the values on the parent page:

    <h2>History</h2>
      <div class="historyNav">
         <ul>
    	<?php
    	 $rows = get_field('history');
              if($rows)
               {
    	     foreach($rows as $row)
    		{ ?>
    		 <li>
                       <a href="<?php echo $row['hisLink']; ?>"><?php echo $row['historyLinkText']; ?></a>
                     </li>
    <?php
     } //end for
    }// endif
     </ul>

    Any help much appreciated

    http://wordpress.org/plugins/advanced-custom-fields/

  2. rikardo85
    Member
    Posted 7 months ago #

    I have found a solution.

    I am using:

    <h2 class="history">Historic shows</h2>
       <ul class="history">
         <?php if(get_field('history', $post->post_parent))
          { ?>
    	<?php while(has_sub_field('history', $post->post_parent)): ?>
    	 <li>
               <a href="<?php the_sub_field('hisLink'); ?>"><?php the_sub_field('historyLinkText'); ?></a>
             </li>
    
    	<?php endwhile;
                }
    	    else {
    		echo 'Coming soon';
    		} ?>
    	</ul>

Reply

You must log in to post.

About this Plugin

About this Topic