get_post_custom_values not working

It most probably means that no custom post values have been retrieved for the key Description that you used. According to the Codex, Returns nothing if no such key exists, or none is entered. Try adding print_r($key_values); on the line just after get_post_custom_values(“Description”); and check if any value is retrieved. To skip this warning(when you … Read more

Query specific number of posts for each post type in specific order

You can use WP_Query() with paged array key to pass the current page number: <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘post_type’ => ‘articles’, ‘posts_per_page’ => 4, ‘paged’ => $paged ); $articles = new WP_Query($args); //////////////////////////////// $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 1, ‘meta_query’ => array( array( ‘key’ => … Read more

Show posts in a list separated by day

Add a variable to hold the previous post’s date, and then add a <br /> or something when it changes. <?php $prev_date=””; // initialize to empty string query_posts($query_string.’&cat=-3′); while (have_posts()) : the_post(); ?> <?php if( strlen( $prev_date ) > 0 && get_the_time( ‘M j’ ) != $prev_date ): ?> <br /> <!– or whatever you … Read more

shortcode for recent custom type post

This seems to work with custom post type : function get_custom_posts( $params ) { extract( shortcode_atts( array ( ‘number’ => ‘1’, ‘excerpt’ => 290, ‘readmore’ => ‘no’, ‘cpt’ => ‘post’, ‘readmoretext’ => ‘Read more’ ), $params ) ); //$latest_posts = get_posts( ‘category=0&numberposts=” . $number . “&suppress_filters=false’); OLD $latest_posts = query_posts( ‘post_type=”.$cpt.”&posts_per_page=” . $number ); wp_reset_query(); … Read more

How to get all post titles starting with numbers and symbols?

Hook into the posts_where filter and add your condition to the query: add_filter(‘posts_where’, function($where){ global $wpdb; return “{$where} AND {$wpdb->posts}.post_title REGEXP ‘^[0-9\$\@\!\?\%]'”; // add other symbols in the regex above ^ }); Then do your query: $my_query = new WP_Query(…); You may want to remove the filter after you get the results (make it a … Read more