WordPress get_posts by category

In all probability you are using a custom taxonomy, and not the build-in category taxonomy. If this is the case, then the category parameters won’t work. You will need a tax_query to query posts from a specific term. (Remember, get_posts uses WP_Query, so you can pass any parameter from WP_Query to get_posts) $args = [ … Read more

Only get_posts of certain post formats

You can’t actually pass a taxonomy-related argument to get_posts(). (Edit: actually, yes you can. The Codex is just somewhat unclear. Looking at source, get_posts() is, at its heart, just a wrapper for WP_Query().) You can pass meta keys/values, and post types, but not taxonomies such as post format. So for this line: $myposts = get_posts(‘numberposts=-1&orderby=post_date&order=DESC’); … Read more

Get term SLUG by term ID

I have bit of trouble understanding your question. Taxonomy (like category) slug or term (like uncategorized) slug? get_term_children() works with terms so I will stick with that. Try this: $term = get_term( $id, $taxonomy ); $slug = $term->slug;

get_posts – get all posts by author id

I’m a bit confused. If you want to get onlya element from the posts array you can get it like this: reset($current_user_posts) – first post end($current_user_posts) – lat post But if you want to get just one post with the get_posts() you can use the posts_per_page argument to limit the results. $args = array( ‘author’ … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)