Derfder
Derfder

Reputation: 3324

How to output pods records in a header.php within a loop using PODS 2

I have a pod called countries and I want to output every record (name) directly in a header.php.

I need it to call from header.php of my theme not from page or template etc.

I assume I need somehow call Pods 2 first.

Then within a loop output {@permalink} and name(title) etc.

Could somebody give me some example of how to do it just with {@permalink} ? Other fields I can do by myself.

I just need the basic e.g. (I know this is wrong. It throws just array() instead of name):

<?php
     $params = array(
        'limit'   => -1  // Return all rows
     );
     $countries = pods( 'countries', $params );

     if ( 0 < $countries->total() ) {
          while ( $countries->fetch() ) {
?>
     <h2><?php echo $countries->field( 'name' ); ?></h2>
<?php
          } 
     } 
?>

Upvotes: 0

Views: 537

Answers (1)

Derfder
Derfder

Reputation: 3324

SOLVED! Instead just

<?php echo $countries->field( 'name' ); ?>

I need to call it like:

<?php echo $countries->field( 'country_field.name' ); ?>

Upvotes: 1

Related Questions