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)

The topic ‘Taxonomy field – display posts with special tag’ is closed to new replies.