Support

Account

Home Forums Front-end Issues Taxonomy field – display posts with special tag

Solved

Taxonomy field – display posts with special tag

  • i have

    custom post type -> weddingfilter (wedding europe, wedding on ship,…..)

    the taxonomy field with tags / select tag name in the admin
    single-…php template

    i will display all post with in the admin selected tag taxonomy in the single template

    Error:
    Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/reisebuero-neu/wp-content/themes/nothing/single-weddingfilter.php on line 26

    Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/reisebuero-neu/wp-content/themes/nothing/single-weddingfilter.php on line 27

    <?php 
    
        $term = get_field('wedding_category');
    
        if( $term ): ?>
    
            <h2><?php echo $term->name; ?></h2>
            <p><?php echo $term->description; ?></p>
    
        <?php endif; ?>
  • this fix my issue

    `<?php
    $tagValue = get_field(‘related_places_by_tag’);
    $args=array(
    ‘tag_id’ => $tagValue,
    ‘posts_per_page’=>6 // Number of related posts to display
    );

    $my_query = new wp_query( $args );
    while( $my_query->have_posts() ) {
    $my_query->the_post();
    ?>
    <div>
    “>
    <?php the_title(); ?>

    </div>
    <?php }
    wp_reset_query();
    ?>’

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.