Display featured image on blog page
Display featured image on blog page
Display featured image on blog page
This is wrong <?php if ( have_posts() ) { while ( have_posts() ) { if ( has_post_thumbnail() ) { echo “<div id=’post_thumbnail’>”; the_post_thumbnail(); echo ‘<h4>’ . get_post(get_post_thumbnail_id())->post_excerpt . ‘</h4>’; echo “</div>”; } the_post(); You are calling your thumbnail before the_post(). Just move the_post() to before if ( has_post_thumbnail() ) {
You can try the following: /** * Get the featured image by post title (Simple version) * * @see http://wordpress.stackexchange.com/a/158344/26350 * @param string $title Post title * @param mixed $size Featured image size */ function get_featured_image_by_post_title_wpse_simple( $title=””, $size=”thumbnail” ) { $obj = get_page_by_title( $title, OBJECT, ‘post’ ); return ( is_object ( $obj ) ) ? … Read more
This is pseudo-code answer. First get the posts you want with get_posts (you can pass the post_type as an argument) Then get the ID of the images you want to set as thumnbail Now do a loop and try with a query similar to this one: “UPDATE wp_postmeta SET meta_value = $image_id WHERE post_id = … Read more
It’s even easier than what you did. . Copy the entire wp structure from the old server to the new, mysql backup the database with creates enabled and import to the new database (preferably blank) . Then just edit the wp configuration file for the new locations of everything (including database name) . I have … Read more
If your theme has support for Post Thumbnails the “Featured Image” metabox will be visible on the on the Edit Post and Edit Page screens. If it isn’t, make sure “Featured Image” is enabled in the screen options on the top right. After clicking the “Set featured image” link insert image. Once you have selected … Read more
Add notice to add image popup
Not sure how you do it in your single.php, but I’m fairly certain not the same way. The main problem is that both the_post_thumbnail() and get_the_post_thumbnail() are generating the img tag output for you – so putting it into the src attribute of an img tag like in your code can’t work. Additionally: The latter … Read more
You shouldn’t have to reload anything you will need to hook this fucntion into a hook so it’s actually run something like this should do it: do_action( ‘init’, ‘toolbox_setup’ ); http://codex.wordpress.org/Function_Reference/do_action
How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?