Tag Info

Hot answers tagged

3

use add_image_size() to define you custom image size 1.register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(hard cropped) } 2.get image in custom image size except featured image of post (functions.php) function ravs_get_custom_image( $featured_img ){ global ...


3

In this case I would add image size in functions.php which registers new image size in my theme and get the re-sized image. Example: Register custom image size (functions.php) if ( function_exists( 'add_image_size' ) ) { add_image_size( 'custom-image', 440, 265, true ); //(cropped) } Get custom image size (functions.php) function ...


3

You can try to add 'meta_key' => '_thumbnail_id', to your input arguments: $args = array( 'numberposts' => 5, 'orderby' => 'date', 'order' => 'DESC', 'post_type' => 'post', 'post_status' => 'publish', 'meta_key' ...


2

You have to set the $single paramter of get_post_meta to false (or don't set it) to get an array. Here is a sped-up version: if ($attachment_id = get_post_meta($post_id, 'featured_image', true)) : elseif ($attachment_id = get_post_meta($post_id, 'upload_single_image', true)) : elseif ($attachment_id = get_post_meta($post_id, 'create_gallery', ...


2

wp_get_attachment_thumb_url() does not accept size as argument. You might be looking for wp_get_attachment_image_src(), but I am not sure on top of my head - too many functions in that corner.


1

You can alter the content of that meta box, which is unusual. Proof of concept: function alter_thumb_box($content, $postID) { return $content.'<input type="radio" name="thumb-size" value="" />'; } add_filter( 'admin_post_thumbnail_html', 'alter_thumb_box', 1, 2 ); You just need to add your fields and then provide a function to save the data, ...


1

You could add a meta box to the post add/edit screen below the featured image box to allow selection of size via a dropdown select menu. You could generate the list from available sizes (via get_intermediate_image_sizes), or just use your small/large strings. The data would be saved as post meta and you would simply get_post_meta() to get the selected size, ...


1

Got it to work by using ACF's custom functions instead of wp's meta functions. Final working result: //Set post thumbnail based on various conditions if (get_post_meta($post_id, 'featured_image', true)) { $attachment_id = get_post_meta($post_id, 'featured_image', true); } elseif (get_post_meta($post_id, 'upload_single_image', ...


1

Sorry, but I don't see any of those parameters in the parameter list for wp_get_recent_posts. $args = array( 'numberposts' => 10, 'offset' => 0, 'category' => 0, 'orderby' => 'post_date', 'order' => 'DESC', 'include' => , 'exclude' => , 'meta_key' => , 'meta_value' =>, 'post_type' => ...


1

A quick experiment with WordPress 3.5.1 shows that when you an image into post from URL, there's no post inserted into the wp_posts or wp_postmeta table - which is why the $images array is coming back empty. You could write some JS on the admin side to create and insert a post asynchronously when you click the insert into post button - otherwise, you could ...


1

If I am reading your question correctly, the problem is that when you set a page so that it has a an archive Loop on it $wp_query and the $posts variable are set to for the index Loop and not for the page the are on. To get information about that page you need get_queried_object. Two lines will show your featured image. $obj = get_queried_object(); echo ...



Only top voted, non community-wiki answers of a minimum length are eligible