a little direction on custom post type

You’re not using templates correctly. You don’t use a custom page template to output custom posts or a custom post archive. There are dedicated templates you need to create to give your post type its own templates. Refer to the Template Hierarchy. For example, if your post type is called event, you need to create … Read more

Sidebar show posts by current category also in single post

Well, let me first describe the full code in code comments. Please read the comments carefully- // By this below code you are returning TRUE to the filter ‘tve_dash_enqueue_frontend’ filter. Which is I think, is turning something on. add_filter( ‘tve_dash_enqueue_frontend’, ‘__return_true’ ); // Here you are hooking the `widget_posts_args` filter with `my_widget_posts_args` function. add_filter( ‘widget_posts_args’, … Read more

Random posts from a pool of posts

Quick & simple: You could simply use post__in in your query with the post IDs of those in your pool, though it might be less easy to maintain when you add and remove posts. Or you could use a meta field and change your query to include it, see the WP_Query documentation. Then either set … Read more

Removing Extra Caption tag around image on post of WordPress

To make sure the shortcode executes, save the content to a variable, then run do_shortcode on the saved variable. <div class=”thecontent” itemprop=”articleBody”> <?php $content = get_the_content(); echo do_shortcode($content); ?> </div> The difference is, echoing just literally echoes whatever has been grabbed. PHP’s built-in functions don’t have any special way to process shortcodes so they just … Read more

Why are my paginated posts always returning the same results?

Found the culprit. I’d foolishly hard-coded the offset to be 0, which must have been overriding WordPress’ query. I changed: $posts_list = new WP_Query([ ‘posts_per_page’ => 1, ‘offset’ => 0, ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, ‘post_type’ => ‘post’, ‘suppress_filters’ => true, ‘paged’ => $paged ]); to: $posts_list = new WP_Query([ ‘posts_per_page’ => 1, ‘orderby’ … Read more