Implementing Zurb’s Interchange Into WordPress

If you haven’t already enabled thumbnails in your theme, add this snippit to your functions.php: add_theme_support(‘post-thumbnails’); Then add this code. add_image_size( ‘responsive-small’, 300, 500 ); add_image_size( ‘responsive-large’, 768, 500 ); Here’s how it works: function( ‘unique_identifier’, width, height); Now the fun part. To use this in your template: <?php if ( have_posts() ) : while … Read more

get_thumbnail_id returns full size image

Hey First add this line into your function.php file add_image_size( ‘custom-size’, 120, 140 ); Then call custom-size like this <?php $thumb_id = get_post_thumbnail_id( $id ); if ( ” != $thumb_id ) { $thumb_url = wp_get_attachment_image_src( $thumb_id, ‘custom-size’, true ); $image = $thumb_url[0]; }?> <img src=”https://wordpress.stackexchange.com/questions/172703/<?php echo $image;?>”> I think it work fine

Set post-thumbnail (with php)?

The issue is going to be the difference in the data required for setting the post thumbnail (an attachment ID) and what’s probably in the custom field: a URL. The way I’m going to suggest is very sloppy: adds more attachments to WordPress. A better way might be to write a custom SQL query where … Read more

How to show featured image CAPTION only if it exist

I am a “little late” but this solution worked great for me. It will show the div only if the caption is not empty. <?php $get_description = get_post(get_post_thumbnail_id())->post_excerpt; the_post_thumbnail(); if(!empty($get_description)){//If description is not empty show the div echo ‘<div class=”featured_caption”>’ . $get_description . ‘</div>’; } ?>

Set post thumbnail as background

The problem here is the_post_thumbnail() doesn’t return image url but the img tag. You can use this code $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); echo ‘<li class=”produkt” style=”background: url(‘. $url.’)”>’;

How to get featured post title & image using JSON API?

I made a shortcut to my image by adding it directly to the API response. //Add in functions.php, this hook is for my ‘regions’ post type add_action( ‘rest_api_init’, ‘create_api_posts_meta_field’ ); function create_api_posts_meta_field() { register_rest_field( ‘regions’, ‘group’, array( ‘get_callback’ => ‘get_post_meta_for_api’, ‘schema’ => null, ) ); } //Use the post ID to query the image and … Read more

Featured image upload finished hook

There is a deault feature available on WP to crop image once you upload. You can edit the image you upload and can crop image with you preferences. How to crop rotate scale and flip images in wordpress WordPress by default is designed to generate 3 types of cropping of any uploaded images (Media) automatically … Read more