Hot answers tagged

2

I'm afraid I don't understand the question perfectly, so I apologize, but, $post_status = 'publish'; Wouldn't that do it? I am missing context though, are you building a query? Because to get all the posts by the current user, something like this would be needed: $args = array( "post_status" => "publish", "author" => get_current_user_id(), ...


2

You should be using get_the_terms(). wp_get_post_terms() queries the db to get post term info, where as get_the_terms() returns the post term objects directly from the post term cache and only queries the db if that info is not available. By default, all post's terms are cached by the query being executed. EDIT I cannot comment (crappy mobile), but there ...


1

Here's one way by using wpdb::get_col() and fetch the id column: $pids = $wpdb->get_col( "SELECT id FROM my_table" ); We could then clean it by integer convert each id with: $pids = wp_parse_id_list( $pids ); Just note the different max value for intval(), depending on 32 or 64 bits systems.


1

post__in accept array of post IDs e.g. array(5, 4, 8, 9); Extending @bravokeyl comment. By default result is Object. As codex suggest you can change the output type of get_results() to these values. OBJECT - result will be output as a numerically indexed array of row objects. OBJECT_K - result will be output as an associative array of row objects, ...


1

Try this, with " tags on .= '<a href="'.get_permalink($id).'"><img src="'.$image['url'].'" /></a>';



Only top voted, non community-wiki answers of a minimum length are eligible