SHOW:
|
|
- or go back to the newest paste.
1 | <?php | |
2 | //get current | |
3 | $post_terms = get_the_terms($post->ID, 'the-creating-artists'); | |
4 | if($post_terms){ //put everything inside this, makes sure that if there is no terms set we wont get just any posts | |
5 | $slug_array = array(); | |
6 | foreach($post_terms as $single_term){ | |
7 | $slug_array[] = $single_term->term_id; | |
8 | } | |
9 | // args | |
10 | $args = array( | |
11 | 'posts_per_page' => 3, | |
12 | 'post_type' => 'artists', | |
13 | 'orderby' => 'rand' | |
14 | 'tax_query' => array( | |
15 | array( | |
16 | 'taxonomy' => 'the-creating-artists', | |
17 | 'field' => 'term_id', | |
18 | 'terms' => $slug_array | |
19 | ) | |
20 | ) | |
21 | - | |
21 | + | |
22 | - | 'field' => '???', |
22 | + | |
23 | - | 'terms' => '???', |
23 | + | |
24 | if($the_query->have_posts()){ | |
25 | echo '<ul>'; | |
26 | while($the_query->have_posts){ | |
27 | $the_query->the_post(); | |
28 | echo '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>'; | |
29 | } | |
30 | wp_reset_postdata(); | |
31 | - | echo '<li><a href=".get_permalink().">'.get_the_title().'</a></li>'; |
31 | + | |
32 | }else{ | |
33 | echo '<p>No related posts</p>'; | |
34 | } | |
35 | }else{ | |
36 | echo '<p>No related posts</p>'; | |
37 | } | |
38 | ?> |