• davidortiz34

    (@davidortiz34)


    So I need some help on the backend aspect of wordpress. I’m using a custom theme that I created. I created a plugin/post type called Foods. With a custom taxonomy called “food_type”. I have blog posts associated with the different food_types. For example I have a food_type called healthy-eating or easy-prep.

    What I’m trying to accomplish is, when you go to the Healthy Eating page I would like it to display the titles of all blogs associated with that custom taxonomy name, then when I go to Easy Prep page to do the same with those posts.

    I was reading about wp_query and the loop and it just made things confusing. Here is what I have so far if someone can help me.

    <?php
    
                        $args = array(
                        'post_type' => 'post',
                        'meta_key'   => 'food_type',
                        'meta_value'  => '$post_id',
                        //'post__in'   => '$post->ID',
                        );
    
                        // The Query
                        $the_query = new WP_Query( $args );
    
                        // The Loop
                        if ( $the_query->have_posts() ) {
                            echo '<ul>';
                                while ( $the_query->have_posts() ) {
                                $the_query->the_post();
                                echo '<li>' . get_the_title() . '</li>';
                                 }
                            echo '</ul>';
                        } else {
                        // no posts found
                        }
                        /* Restore original Post Data */
                        wp_reset_postdata();
    
                        ?>

    Any help would be

    [Moderator Note: No bumping. If it’s that urgent after just 1 hour, please consider hiring someone instead.]

  • The topic ‘WP Query’ is closed to new replies.