Use call within call
-
<ul> <?php $args = array( 'numberposts' => 5, 'post_type' => 'post', 'tag' => '<?php echo $post->post_name; ?>', 'field' => 'slug' ); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> <?php endforeach; ?> </ul>
This works when I enter a tag in the ‘tag’ field but I can’t get it to work when it uses the tag as the post name. I have a custom post type where there is a tag with the same slug for each post. So how can I get this call to work?
- The topic ‘Use call within call’ is closed to new replies.