dekzgimutao
Member
Posted 1 year ago #
I have three tables.
posts
| id | title |
+---------+-----------+
| 1 | hello |
| 2 | goodbye |
+---------+-----------+
posts_tags
| tag_id | post_id |
+---------+-----------+
| 1 | 1 |
| 2 | 1 |
| 2 | 2 |
+---------+-----------+
tags
| id | name |
+---------+-----------+
| 1 | news |
| 2 | photos |
+---------+-----------+
I want to be able to select the tags inside a post, and have this as a result
post.id post.title tags
------------------------------------
1 hello news,photos
2 goodbye photos
anyone? thanks
dekzgimutao
Member
Posted 1 year ago #
Yes sir I've tried it It works on themes template but I'm creating a simple plugin which would show the follwing: Post Title Post Url and The TAGS inside each post a got it working with the title and url, i've tried different codes and so far I got a word Array and nots it value but when I print_r the variable it shows all the infomation of the TAGS
<?php
//echo "<br><br>";
global $wpdb;
$postID = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE (post_type = 'post')
AND (post_status = 'publish')
AND (post_password = '')
");
echo '<ul id="post_links">';
foreach($postID as $post_link) {
?>
<tr> <td><a href="<?php echo get_permalink($post_link); ?>"><?php echo get_the_title($post_link);?> </a></td>
<td><?php echo get_permalink($post_link); ?></td>
<td><?php
echo get_the_tags($post_link);
$postid = $post->ID;
echo get_the_tags($postid);
print_r(get_the_tags($post_link));
echo the_tags();
?>
these is my code sir, Thanks I hope I can figure these out