Home Forums Front-end Issues Options Page Post Object field post on category.php


Options Page Post Object field post on category.php

  • Have you ever experimented with using the post object field on the options page to show post data on a category page?

    I have been trying my best to somehow show fields from the queried post object, but I cannot seem to get it.

    Here is the code from my category.php file:

                // get the current taxonomy term
                $term = get_queried_object();
                $post_object = get_field('dist_feat_posts_01', $term);
                if ($post_object):
                    // override $post
                    $post = $post_object;
                    $image = get_field('square_image', $term);
                    echo '<pre>';
                    echo '</pre>';
    					<img src="<?php the_field('square_image'); ?>">
    			    	<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    			    	<span>Post Object Custom Field: <?php the_field('square_image', $post_object->ID); ?></span>
    			    <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly?>
    			<?php endif; ?>

    dist_feat_posts_01 = return format, Post Object
    square_image = return value, Image Array

    Feeling pretty lost 🙂
    Any help is greatly appreciated.

Viewing 1 post (of 1 total)

The topic ‘Options Page Post Object field post on category.php’ is closed to new replies.