Custom Taxonomies Incorrectly Counting Revisions?

Hi @berkleebassist: It’s hard to verify your issue without admin access to your site and your database but I can give you some direction that might help. There are two functions in /wp-includes/taxonomy.php that update taxonomy term count: wp_update_term_count_now() and _update_post_term_count(). They are located (in WordPress v3.0.1) at line 2454 and line 2049, respectively. Both … Read more

Specify number of posts in my ‘tax_query’

Never user query_posts, under any circumstances. Use WP_Query instead, which is how query_posts works internally, but without the trickery and downsides. You’ll also find that the WP_Query documentation gives you explanations for every parameter, including what you are trying to do: posts_per_page (int) – number of post to show per page (available with Version 2.1, … Read more

How do I create Comma Separated list of attached image ids?

You can try this one-liner, within the loop, instead of all your above code: $ids = join( ‘,’, wp_list_pluck( get_attached_media(‘image’ ), ‘ID’ ) ); where we pluck out the ID’s from the get_attached_media() output. Another approach would be to use: $ids = join( ‘,’, get_attached_media( ‘_image_ids’ ) ); where we’ve introduced a new input parameter … Read more

How to show related posts by category or custom post type?

<?php $related = get_posts( array( ‘category__in’ => wp_get_post_categories($post->ID), ‘numberposts’ => 5,’post_type’ => ‘news’, ‘post__not_in’ => array($post->ID) ) ); if( $related ) foreach( $related as $post ) { setup_postdata($post); ?> <li> <?php the_post_thumbnail(); ?> <a href=”https://wordpress.stackexchange.com/questions/151897/<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?></a> </li> <?php } wp_reset_postdata(); ?>

Publish Post After Click On A Link

When the post is created and set to pending, build a unique identifier for auto-publishing, for example: $unique = md5( $post->post_content ); add_post_meta( $post->ID, ‘_auto_publish’, $unique ); Now create a link for the email: $link = get_permalink( $post->ID ); $link = add_query_arg( array( ‘autopublish’ => $unique, ‘pid’ => $post->ID ), $link ); Send this link … Read more

Programmatically inserting page breaks

Overriding the default page breaking – with external content parts The page breaking takes place in the WP_Query::setup_postdata() method, when we call the_post() in the loop. The page parts are stored in the global $pages array and fetched with get_the_content() function. This happens all before the the_content filter is applied to the content. We can … Read more

Pagination for Pages and Posts

Post Navigation Here’s the way its done in the Twenty Twelve themes single.php file however it looks like Twenty Fourteen has a better solution which works for pages as well. <nav class=”nav-single”> <h3 class=”assistive-text”><?php _e( ‘Post navigation’, ‘twentytwelve’ ); ?></h3> <span class=”nav-previous”><?php previous_post_link( ‘%link’, ‘<span class=”meta-nav”>’ . _x( ‘&larr;’, ‘Previous post link’, ‘twentytwelve’ ) . … Read more