Support » Fixing WordPress » getting Categories assoc with post

  • i’m using a plugin that uses php a little differently than i’m familiar with (i’m only a novice) – i want to get the categories from the query the plugin uses, like so:

    $pbcresults = $wpdb->get_results("SELECT *
    FROM $wpdb->posts, $wpdb->term_relationships,$wpdb->term_taxonomy
    $wpdb->posts.post_status = 'publish'
    AND $wpdb->posts.post_type = 'post'
    AND $wpdb-> = $wpdb->term_relationships.object_id
    AND $wpdb->term_taxonomy.term_id =$catid_in
    ORDER BY $wpdb->posts.post_date DESC , $wpdb->posts.post_title ASC
    LIMIT $count");
    foreach ( $pbcresults as $pbcresult )
    	$the_output .= '<h1 class="post-title"><a>ID) . '">' . apply_filters('the_title', $pbcresult->post_title) . '</a></h1>';
    	 $the_output .=  apply_filters('the_content', $pbcresult->post_content);
    // need to get the Cats and Tags here...

    i could figure out how to get the post_content, but can’t get an array from this query – if someone could help me, i’d appreciate it…


Viewing 4 replies - 1 through 4 (of 4 total)
  • <?php
      'cat' => $catid_in,
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        the_content('Read the rest of this entry &raquo;');
    wp_reset_query();  // Restore global post data stomped by the_post().

    See Template_Tags/the_category or Template_Tags/get_the_category

    thanks – not quite sure how incorporate the_category(); into

    $the_output .= '<div class="post-meta"><div class="row">';
    $the_output .=  apply_filters('the_content', $pbcresult->post_content);
    $the_output .=   '<em>'. the_category(); . '</em>';
    $the_output .= '</div></div>';

    don’t know where to place your query – within the $the_output .= ”; ?

    That code was meant to replace your code and to show another way of retrieving and displaying post, but you’d need to add the necessary div elements.

    oh – :o)
    thanks !!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘getting Categories assoc with post’ is closed to new replies.