Get Featured Image URL By Size

get_the_post_thumbnail_url(get_the_ID(), ‘thumbnail’); get_the_post_thumbnail_url(get_the_ID(), ‘medium’); get_the_post_thumbnail_url(get_the_ID(), ‘large’);

Read More

Displaying Future Posts

To display future posts, just include the ‘post_status’ as part of the query: $args = array(      ‘post_status’ => array(‘publish’,’future’),     ‘post_type’ =>  ‘blog’,     ‘posts_per_page’ => 21,     ‘paged’ => $paged    );

Read More

WordPress – Category Page Not Showing Posts With Custom Post Type

I had created a post type for news articles. Unfortunately, when categorizing the pages, and trying to view the category from the front end, those posts weren’t appearing.   Apparently that doesn’t work for cusotm post types by default. To get them to show, add this to the functions.php file: function namespace_add_custom_types( $query ) {    if( (is_category() || is_tag()) && $query->is_archive() && empty( $query->query_vars[‘suppress_filters’] ) ) {       $query->set( ‘post_type’, array(        ‘post’, ‘news’       ));    } } […]

Read More

WordPress Post Type Supports Options

– title – editor – comments – revisions – trackbacks – author – excerpt – page-attributes – thumbnail – custom-fields – post-formats’

Read More

WordPress Enable Tags for Custom Post Type

Just add this line when you register the post type: ‘taxonomies’ => array(‘category’, ‘post_tag’) So something like this for all of the code: register_post_type( ‘customtype’,    array(       ‘labels’ => array(          ‘name’ => __( ‘CustomType’ ),          ‘singular_name’ => __( ‘CustomType’ )       ),       ‘supports’ => array(          ‘title’,’page-attributes’,’description’,’editor’, ‘thumbnail’       ),       ‘public’ => true,       ‘has_archive’ => true,       ‘rewrite’ => array(‘slug’ => ‘customtype’),       ‘taxonomies’ => array(‘category’, ‘post_tag’)    ) );

Read More