G
G
godsplane2020-06-23 09:50:33
WordPress
godsplane, 2020-06-23 09:50:33

How to display a custom field on the taxonomy page through Pods?

I'm trying to render a custom services_tax taxonomy field created via the pods plugin.
But he just ignores my attempts.
I tried both through $pods->display
and through get_term_meta, but for some reason nothing is displayed. Posts never had this problem before.
Perhaps the problem is that I'm using this output not in a loop? But what then should I add a loop to make it work?

<div class="prices-item">
            <?php 
             var_dump(get_query_var('services_tax'));
             $term_id = get_query_var('services_tax'); // текущая рубрика, предположим мы зашли в рубрику 65
             echo get_term_meta( $term_id, 'price1', false ); // выведет: Какой хороший день
              
     
            ?>

          </div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Ermilov, 2020-06-23
@sergeiermilov

You can try a couple of these options:

<?php
$servicesTax = get_post_meta($post->ID, 'services_tax', true);
echo $servicesTax;
?>

And the second option:
<?php 
$servicesTax = get_post_custom_values( 'services_tax' );
foreach ( $servicesTax as $key => $value ) {
echo $value;
};  ?>

And the output should be in a loop between:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

and
<?php endwhile; ?>

G
godsplane, 2020-06-23
@godsplane

$price = pods_field_display( 'services_tax', $term->term_id, 'price1', false);
setup_postdata($price);
echo $price;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question