Override Blog pages show at most with get_posts

In your code example, you’re mixing two things. With get_posts() you’ll get an array of posts, which you can use in a custom loop. $args1 = array( ‘post_type’ => ‘wpcp-events’ ‘numberposts’ => -1, ); $events = get_posts($args1); if ( $events ) { foreach ( $events as $post ) { setup_postdata( $post ); // make Loop … Read more

get_posts returns all posts

You are not using correctly the tax_queryargument. This argument takes array of tax query arguments arrays, to allow for complex queries with multiple taxonomies. You can learn more in the WP_Query documentation This is the correct way: $malls_args = array( “post_type” => “mall”, “tax_query” => array( array( “taxonomy” => “shop”, “field” => “name”, “terms” => … Read more

Return number of all custom posts type by author in all statuses

The code you shared worked fine for me, so either your value for $user_id or $post_type is incorrect – or the user actually has no posts of the post type you’re searching for. function get_user_posts_count($user_id, $post_type) { $args[‘author’] = $user_id; $args[‘fields’] = ‘ids’; $args[‘post_type’] = $post_type; $args[‘fields’] = ‘ids’; $args[‘blog_id’] = 4; $args[‘post_status’] = ‘any, … Read more

Post Filtering by GET URL parameters

You have to filter the posts in the query arguments. Try: $mycat = $_GET[‘category’]; $arg = array( ‘type’ => ‘post’, ‘order’ => ‘ASC’, ‘category_name’ => $mycat ); Just remove the square brackets from the link, or use: $mycat[0] $mycat = $_GET[‘category’]; $arg = array( ‘type’ => ‘post’, ‘order’ => ‘ASC’, ‘category_name’ => $mycat[0] );

Recent posts on homepage: different thumbnail based on logged in status and post category

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() to restore … Read more

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