get_the_post_thumbnail($post->ID, ‘thumbnail’); not working. How can I solve this?

The problem of showing the thumbnail twice is because of your the_content(); which is defined in the content-page.php file that has the line the_post_thumbnail(); that will get the featured image. so intead of using the the_content() just use the get_the_content() function to get only the content without the featured image. Let me know if that … Read more

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