Get post title foreach post in loop and pass outside the loop
-
I want to exclude terms that have same name as post titles from loop. How can I pass the post titles for each post from the loop to an array outside the loop
This is the loop for example
<ul> <?php global $post; $args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata($post); ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
and I want all the post_titles to pass to this code to exclude terms with same names as post titles
<?php echo my_get_the_term_list( $post->ID, $taxonomy, '', ' ', '', array($post_title1, $post_title2,) ); ?>
Thanks
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Get post title foreach post in loop and pass outside the loop’ is closed to new replies.