WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Query Connected Posts (1 post)

  1. stinkyleaf
    Member
    Posted 3 years ago #

    So we have an article we would like to connect to some media posts. How do we in our template query if the post has a connection then display the content we are defining in the following code. For example, if post has a connection (using posts to posts) then query the specific content of that post which we already have in place in the below code.

    <div class="secendary-wrap">
                    <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1;
    					$temp = $wp_query;
    					$wp_query= null;
    					$wp_query = new WP_Query();
    					$wp_query->query("paged=$page&cat=10");
    					if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
    					while ($wp_query->have_posts()) : $wp_query->the_post();?>
                        <div style="margin-right:8px;">
                 		<!--Run Timthumb Image Resize Script -> post-img to 312x126px - Zoom Crop of 0 - Quality 75% -->
    					<?php if( get_post_meta($post->ID, "post-img", true) ): ?>
                        <div class="frontpage-widget-img">
                        <a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php bloginfo('template_directory'); ?>/js/timthumb.php?src=<?php echo get_post_meta($post->ID, "post-img", $single = true); ?>&w=312&zc=2&q=75" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></a></div>
                        <?php else: ?>
                        <?php endif; ?>
                        <!--Title, Author, Dat/Time -->
    				    <?php include (TEMPLATEPATH . '/inc/title_author_date_time.php' ); ?>
                        <!--Truncate excerpt number = word count -->
                        <p class="excerpt-widget"><?php $excerpt = get_the_excerpt(); echo string_limit_words($excerpt,40); ?></p>
                     	<!--FOOTER LINK NAV -->
    					<?php include (TEMPLATEPATH . '/inc/widget_footer_nav.php' ); ?>
    					</div><!--Close Metro-->
    				 <?php endwhile ?>
    					<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?>
    					<?php $wp_query = null; $wp_query = $temp; ?>
                    </div><!--Close seconday wrap 1-->
    				<?php wp_reset_query(); ?>

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic