get_posts returning empty array
Try “post_type” => array(‘carellcars’, ‘ccf’, ‘attachment’),
Try “post_type” => array(‘carellcars’, ‘ccf’, ‘attachment’),
Array merging multiple get_posts throwing Undefined offset error
I think I found how to do it: setting ‘numberposts’ => 1, will retrieve only one (the first) post.
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
Answering my own post here, it seems that WP Super Cache has a dedicated setting (in Advanced section) to not cache urls that have a GET parameter. Once that is checked, problem seems not to replicate for me anymore. So indeed the root problem is that cached files do not run the php code anymore, … Read more
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
<?php $congigs = get_posts(‘post_type=items&author=”.$current_user->ID.”&tag=’.$bkpostid.’&numberposts=-1′); foreach($congigs as $posts) : $title = $posts->post_title; ?> <li><?php echo $title; ?></li> <?php endforeach; ?>
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
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’);
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