WordPress get_categories & listing recent post thumbnail

Did some playing about, managed to get it working. <?php /* Template Name: Festivals – United States */ ?> <?php get_header(); ?> <div id=”left_full”> <?php $args = array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘child_of’ => ‘3592’ ); $temp_query = $wp_query; $categories = get_categories($args); foreach($categories as $category) { query_posts(“posts_per_page=1&cat=$category->cat_ID”); if (have_posts()) : while (have_posts()) : … Read more

Getting featured image with direct $wpdb within plugin

That is not how you would query for a featured image. This: $thumb = $wpdb->get_var(“SELECT ID FROM $wpdb->posts where post_parent=”$value” and post_type=”attachment””); Should be: $thumb = $wpdb->get_var(“SELECT meta_value FROM $wpdb->postmeta where meta_key = ‘_thumbnail_id’ and post_id = ‘$value'”); That is assuming that $value is a post ID. “Featured” images are attachments, but not all attachments … Read more

Is wordpress compressing my images? if so, how to prevent it?

A nice explanation is at WPMUdev: http://premium.wpmudev.org/blog/how-to-change-jpeg-compression-in-wordpress/ According to their tutorial, you’d need to add the following to your functions.php add_filter( ‘jpeg_quality’, create_function( ”, ‘return 100;’ ) ); They also suggest regenerating your thumbnails once the change is made so previously uploaded images will be affected by the quality change.

Get last post in category thumbnail

Try this: <?php $the_query = new WP_Query( ‘showposts=1&cat=55’ ); if($the_query->have_posts()) : while ($the_query -> have_posts()) : $the_query -> the_post();?>       <a href=”https://wordpress.stackexchange.com/questions/144864/<?php the_permalink(); ?>”><?php the_post_thumbnail();?></a> <?php endwhile; endif; /* Restore original Post Data */ wp_reset_postdata();?> Replace cat=55 with the category ID you want and/or replace showposts=1 with the number of latest posts you want to show … Read more

Retrieve a post’s featured image with PHP outside of WordPress

The most common way to achieve those features is to implement some sort of interface, usually in JSON or XML. To do this, you either use a plugin (http://wordpress.org/plugins/json-rest-api/ <= Will probably part of core in WP 4.0) or do the AJAX function yourself. An example would be: add_action( ‘wp_ajax_get_thumbnail’, ‘ajax_get_thumbnail’ ); add_action( ‘wp_ajax_nopriv_get_thumbnail’, ‘ajax_get_thumbnail’ … Read more

Set Featured Image not opening – Stuck at loading

If this is still a problem, then you can find my answer on wordpress.org’s support forum, it might help: wordpress.org/support/topic/resize-failure-on-some-images-with-odd-message This is a part of a code from the jQuery library, to be specific this part is responsible for handling callbacks. It is displayed, because the reponse from wordpres is unparsable JSON data. If you … Read more