How do you get the full size url of an attachment image

I think you’re overthinking the system. Unfortunately the nomenclature isn’t helping. The Thumbnail here is the actual image when you use get_the_post_thumbnail_url(). as an example. Say today you uploaded an image called myimage.jpg. That would go, if you’re storing images by date into this directory: /wp-content/uploads/2017/07/myimage.jpg. Now when you call : $featured_img_url = get_the_post_thumbnail_url(‘full’); //(or … Read more

How to display Related Posts based on number of taxonomy terms matched

Let’s split the problem up in three bits: retrieving the related posts from the database, sorting them and displaying the result. Post retrieval This is possible using the taxonomy parameters offered in WP_Query. Let’s first retrieve the category of the current post and find their IDs: $categories = get_the_terms( get_the_ID(), ‘news-category’ ); foreach ( $categories … Read more

How do I control the output of a custom post type in the loop?

I assume that you’re making your custom post type in a plugin if you mean for it to work with any theme. In that case, I would suggest building your templates in your plugin, and call all your meta data there. Example: /* Filter the single_template with our custom function*/ add_filter(‘single_template’, ‘my_custom_template’); function my_custom_template($single) { … Read more

Meta Box on Custom Post Type not saving

Hi @George Wiscombe: So close, yet so far! (I know the pain, I’m there often. 🙂 You almost had it but are using the wrong hook to do the post meta update. Use the ‘wp_insert_post_data’ hook instead of the ‘save_post’ hook: <?php if (!class_exists(‘YourSite_Portfolio’)) { class YourSite_Portfolio { static function on_load() { add_action(‘init’,array(__CLASS__,’init’)); add_action(“admin_init”,array(__CLASS__,’admin_init’)); add_action(‘wp_insert_post_data’,array(__CLASS__,’wp_insert_post_data’),10,2); … Read more