• Hi!

    I’m not sure if this is a right title for my problem (I’m totally new to WordPress, same goes to php) so I’m going to represent my problem and what I’m came up with so far in hope somebody will be patient enough to help me:-)

    I’m creating a website based on twentythirteen theme and for my project I needed custom posts type. Used Custom Post Type UI plugin for this.
    First custom post is called “area” and second “people”. For them I have created a taxonomy which is called “area_taxonomy” (I assigned this for both “area” and “people” using Custom Post Type plugin).

    Now I want to display on a custom page, “area” posts and add a titles with permalinks of the “people” posts that have the same taxonomy term assigned to each and every post. So far I’ve came with something like this:

    <?php while ( have_posts() ) : the_post(); ?>
    
    				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    					<div class="entry-content">
                                                <?php the_content(); ?>
    
                                                <?php $loop_post_type_area = new WP_Query(array('post_type' => 'post_type_area', 'posts_per_page' => 20 )); ?>
                                                <?php while($loop_post_type_area->have_posts()) : $loop_post_type_area->the_post(); ?>						
    
                                                    <?php if ( has_post_thumbnail() && ! post_password_required() ) : ?>
                                                        <a href="<?php the_permalink(); ?>" rel="bookmark"><div class="entry-thumbnail"><?php the_post_thumbnail(); ?></div></a>
                                                    <?php endif; ?>
    
                                                    <?php $loop_people = new WP_Query(array('post_type' => 'post_type_people', 'area_taxonomy' => 'some_variable???' )); ?>
    
                                                        <?php while($loop_people->have_posts()) : $loop_people->the_post(); ?>
                                                            <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
                                                        <?php endwhile; ?>
    
                                                <?php endwhile; ?>
    
                                                <?php wp_link_pages( array( 'before' => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentythirteen' ) . '</span>', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
                                            </div><!-- .entry-content -->
    
    				</article><!-- #post -->
    
    				<?php comments_template(); ?>
    			<?php endwhile; ?>

    In the loop where I wrote “some_variable???” I’ve tried to insert specific taxonomy term and it worked just as I wanted, just not dynamically.

    I apologize if the title is not very accurate or if the description of my problem isn’t very good but (as I said) I’m a beginner in this sort of things. It’s a third day of my struggle, I’ve searched everywhere and probably answer was right in front of me, but a don’t have a skill to see it.

    Please help!

Viewing 1 replies (of 1 total)
  • Look at the function get_the_terms(). You would get all terms for the ‘area’ taxonomy and use the first one in the returned array (assuming that each people post has only one). That object should have the information you need in it.

Viewing 1 replies (of 1 total)

The topic ‘How to dynamically display one category custom posts?’ is closed to new replies.