Advertisement
salmancreation

wordpress query custom code new

Nov 6th, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <h2>Latest News</h2>    
  2. <?php $link = get_the_title(); ?>
  3. <?php $portfolioloop = new WP_Query( array( 'post_type' => 'news' ) ); ?>
  4. <?php while ( $portfolioloop->have_posts() ) : $portfolioloop->the_post(); ?>  
  5.     <?php $post_link = get_post_permalink(); ?>                        
  6.         <?php  if (get_field('featured_companies') != "") { ?>
  7.             <?php foreach(get_field('featured_companies') as $post): ?>
  8.                 <?php $company = get_the_title($post_object->ID); ?>
  9.                 <?php if ($company == $link) { ?>
  10.                     <a href="<?php echo $post_link; ?>">News item 1</a>
  11.                 <?php } ?>
  12.             <?php endforeach;?>
  13.         <?php } ?>
  14. <?php endwhile; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement