Memory issue with get_posts( ) function

Running a no limit query is very likely the cause of your memory issues. So you might want to change your query. If still you need to do this way, you can use the fields option, it returns post IDs only and will save a lot of memory usage – example below: $your_query = get_posts( … Read more

Exclude post format from get_posts

You just need to set the operator parameter to ‘NOT IN’ (see Codex on tax queries). Untested, but for your purposes: $args = array( ‘post_type’=> ‘post’, ‘post_status’ => ‘publish’, ‘order’ => ‘DESC’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-aside’ ), ‘operator’ => ‘NOT IN’ ) ) );

Getting only a specific post type with get_post?

$the_posts = get_posts(array(‘post_type’ => ‘post_type_name’)); That will get all posts from the post type called “post_type_name” so replace that with whatever custom post type you are using. I mean this in the nicest possible way, but you should probably read the documentation as this is a pretty well documented feature that isn’t too hard to … Read more

Get all pages and posts with get_pages() or get_posts()

get_pages does not work with posts or post types that is not hierarchical like pages, so if your post type is hierarchical like posts, it would not work This function can also retrieve other post types using the ‘post_type’ parameter, but the type must be hierarchical like pages, or the function will return false. If … Read more

get_posts not working as expected

With get_posts(), try using the category ID instead of the category slug. For example: // Carousel articles $args = array( ‘numberposts’ => 3, ‘orderby’ => ‘date’, ‘category’ => 1 ); $carousel = get_posts($args); // News articles $args = array( ‘numberposts’ => 3, ‘orderby’ => ‘date’, ‘category’ => 2 ); $news = get_posts($args); // Featured articles … Read more

get_posts() not working in functions.php

This is a bandaid, not a fix. But it seems there is a bug within WP_Query, so I had to modify the query right before it was actually run in order for the post_type parameter to not be ignored. 1) I changed get_posts() to a WP_Query 2) I added this to my functions.php file: function … Read more

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