Tag Info

New answers tagged

1

First, you're using prepare() wrong. Should be this: $wpdb->prepare("SELECT Active FROM testers WHERE user_id = %s", $user_id) If you have any debugging enabled, it will throw an error from your code. Which may make your location header not work properly. Second, the get_var() function indeed returns null when there are no results. Third, setting a ...


-2

You use the best way:) Maybe, if you want to optimize your query you can use posts 2 posts plugin. You will not need to filter the query. Link - https://github.com/scribu/wp-posts-to-posts/wiki


1

There are several problems with your code. Unless you, or a plugin, has added wp_frm_item_metas to $wpdb, $wpdb has not idea what $wpdb->wp_frm_item_metas is. You will get an "Undefined Property" error, and your query won't work. You can't just use $wpdb-> plus any table name. That won't work. You have to add the property to $wpdb, which isn't that ...


0

You will need to join four table to get cateogries of custom post type "review" wp_term_relationships wp_posts wp_term_taxonomy wp_terms by using following query you can get list of categories applied to your custom post type: SELECT * FROM wp_term_relationships AS tr LEFT JOIN wp_posts AS p ON tr.object_id = p.ID LEFT JOIN wp_term_taxonomy AS tt ON ...


1

You can't use prepare for column names, and you can't really use it for the sort order either. prepare will always quote the string. You will need to swap in the values yourself. Rather than try to "sanitize" the data, I'd use a white-list approach. $orderby = array( 'date' => 'post_date', // etc ); $sortorder = array( 'asc' => 'ASC', 'desc' ...



Top 50 recent answers are included