How to use custom fields to enable sticky posts on custom post types?

You can achieve this with ACF. Create a custom field checkbox (just a simple boolean) for your custom post type. Below an example of overriding the main loop in archive template : function order_cpt_by_stickyness( $query ) { if(!is_admin() && $query->is_main_query() && is_post_type_archive(‘my_custom_postype’)) { $query->set( ‘meta_key’, ‘my_sticky_custom_field’); $query->set( ‘orderby’, [‘meta_value’ => ‘DESC’, ‘date’ => ‘DESC’]); } … Read more

Underscores.me retrieve next / previous post thumbnail in post_nav function

I solved the problem by using get_the_post_thumbnail() instead of the variables $prevthumbnail and $nextthumbnail. function THEMENAME_post_nav() { // Don’t print empty markup if there’s nowhere to navigate. $previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, ”, true ); $next = get_adjacent_post( false, ”, false ); if ( ! $next && ! … Read more

Frontend Post Excerpt field mapping

I haven’t tried the Gravity Forms plugin but if you are using the wp_insert_post function to insert the new post, you just use ‘post_excerpt’. example: $new_post = array( ‘post_title’ => ‘Post Title’, ‘post_content’ => ‘Post Content’, ‘post_status’ => ‘publish’, ‘post_excerpt’ => $custom_excerpt_field ); wp_insert_post($new_post); Not sure if I completely understand your question, so I’ve misunderstood … Read more

Show all post titles

Have not tested it but this should get you to your goal. I believe Accore LTD has it correct as well, except your slide #s will be post ID, instead of slide-1, slide-2 <div class=”content”> <?php if ( have_posts() ) : ?> <h2><?php single_cat_title(”,true); ?></h2> <div> <ul> <?php $inc = 1; while ( have_posts() ) … Read more

Post taxonomy from exif data

Retrieving attachment image EXIF data As “a plugin” won’t help later visitors, let’s start off with how to retrieve that: # Get the post ID: Use one of the following. Preferred is the API function get_the_ID() # $GLOBALS[‘post’]->ID; # global $post; $post->ID; # get_the_ID(); $meta = wp_get_attachment_metadata( get_the_ID(), false ); # Fetch the EXIF data … Read more

Show the author’s count of total amount of posts assign to a custom taxonomy term

/** * Get the author post count for a tax query. * * @link http://wordpress.stackexchange.com/q/159160/1685 * * @param array $tax_query * @return int */ function wpse_159160_get_author_posts_by_tax( $tax_query ) { global $wpdb; $where = get_posts_by_author_sql( ‘post’, true, get_post()->post_author ); $tax_query = new WP_Tax_Query( $tax_query ); $sql = $tax_query->get_sql( $wpdb->posts, ‘ID’ ); return ( int ) $wpdb->get_var( … Read more

Get user’s most published categories

This can be done easily with $wpdb, here’s my approach: function GetTop2CategoryByUser($user_id, $taxonomy){ global $wpdb; $results=$wpdb->get_results( $wpdb->prepare( ” SELECT tt.term_id as category, COUNT(p.ID) as count FROM $wpdb->posts p JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id JOIN $wpdb->term_taxonomy tt ON tt.term_taxonomy_id = tr.term_taxonomy_id AND (tt.taxonomy = %s AND tt.term_taxonomy_id != 1) WHERE p.post_author = %s GROUP … Read more