How to get a custom post with the largest ID (not the last post by date)

Turns out, I was kind of wrong when I tried to get the largest ID. What I needed was to get posts by, and then to sort by, the order number itself! Here’s what I came up with: $num_args = array( ‘post_type’ => ‘my_store_order’, ‘post_status’ => array(‘mystatus_1’, ‘mystatus_2’, ‘mystatus_N’), ‘numberposts’ => 1, ‘meta_query’ => array( … Read more

How to use get_posts to filter against a single post id?

Nevermind, all of these methods work if I add the post_type parameter to the query: get_posts(array( ‘ID’ => 12345, ‘post_type’ => array(‘any’), )); get_posts(array( ‘p’ => 12345, ‘post_type’ => array(‘any’), )); get_posts(array( ‘post’ => 12345, ‘post_type’ => array(‘any’), )); get_posts(array( ‘post__in’ => array(12345), ‘post_type’ => array(‘any’), )); This is a really stupid design decision; any … Read more

Paging result of get_posts in function

add this pagination function: function pagination( $query, $baseURL = get_bloginfo( $url ), $echo = true ) { $page = $query->query_vars[“paged”]; if ( !$page ) $page = 1; $qs = $_SERVER[“QUERY_STRING”] ? “?”.$_SERVER[“QUERY_STRING”] : “”; // Only necessary if there’s more posts than posts-per-page if ( $query->found_posts > $query->query_vars[“posts_per_page”] ) { $re=”<ul class=”paging”>”; // Previous link? … Read more

Get posts in archive page

Instead of using the number 3, you get the current category by doing the following: $cat_ID = get_query_var(‘cat’); $posts = get_posts(‘cat=”.$cat_ID.”&numberposts=5&offset=0’);

Single random post in homepage

how to show the full post: http://codex.wordpress.org/Customizing_the_Read_More#More_about_.24more I want all the things I get in single.php possibly copy all the code from within the loop of single.php into the loop of your random post. my custom code … doesn’t work in index the in_category() code might only work within the loop or needs refining – … Read more

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