Support » Everything else WordPress » post_category not assigned to posts

Viewing 5 replies - 1 through 5 (of 5 total)
  • post_category is no longer used. Categories are now just a type of term, and the term_relationships table holds the links between the posts table and the term_taxonomy table (which defines terms as part of a taxonomy.. ‘category’ in your case).

    If you want all the posts in categories (3,5,6,7), you need to do something more like this:

    SELECT DISTINCT ID, post_title FROM $wpdb->posts as p
    INNER JOIN $wpdb->term_relationships AS tr ON
    (p.ID = tr.object_id AND
    tr.term_taxonomy_id IN (3,5,6,7) )
    INNER JOIN $wpdb->term_taxonomy AS tt ON
    (tr.term_taxonomy_id = tt.term_taxonomy_id AND
    taxonomy = 'category');

    thanks thanks thanks thanks!!! You are my hero!!! 😀

    Hello Otto. I’m looking for specialist’s help. I’m sure you can help me.

    I would like to have something like this :

    <select>
    <option value=”{term_taxonomy_id}”>Category WP 1</option>
    <option value=”{term_taxonomy_id}”>Category WP 2</option>
    <option value=”{term_taxonomy_id}”>Category WP 3</option>
    <option value=”{term_taxonomy_id}”>…</option>
    </select>

    What is the MySQL Request in order to have all my categories in a select box ?

    Thank you and excuse my poor english (i’m a french guy) !

    Hello Otto. I’m looking for specialist’s help. I’m sure you can help me.

    I would like to have something like this :

    <select>
    <option value="{term_taxonomy_id}">Category WP 1</option>
    <option value="{term_taxonomy_id}">Category WP 2</option>
    <option value="{term_taxonomy_id}">Category WP 3</option>
    <option value="{term_taxonomy_id}">...</option>
    </select>

    What is the MySQL Request in order to have all my categories in a select box ?

    Thank you and excuse my poor english (i’m a french guy) !

    Hello! I’ve got a related question: I’m trying to relate a query to the taxonomy table for each ID that I pull out to see if that post is in a category. Here’s my original query:

    $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date), ID
      		FROM $wpdb->posts WHERE MONTH(post_date) = $thismonth
      		AND YEAR(post_date) = $thisyear
      		AND post_status = 'publish' AND post_type='post'
      		AND post_date < '" . current_time('mysql') . '\'', ARRAY_N);
      	if ( $dayswithposts ) {
      		$counter = 0;
    		foreach ( $dayswithposts as $daywith ) {
    
      			$daywithpost[] = $daywith[0];
    
    			//echo $daywithpost[$counter]. " | ";
    			//$counter += 1;
      		}
      	} else {
      		$daywithpost = array();
      	}

    Is there anyway to:
    – Lookup the ID to the Taxonomy table
    – Check for the category name of number
    – Only put those that pass this test into the array

    -Brandon

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘post_category not assigned to posts’ is closed to new replies.