Tag Info

New answers tagged

1

You can use this plugin https://wordpress.org/plugins/quick-featured-images/ In description it says "You can also see posts with no featured image at a glance." But from code side, wordpress manages images, documents any media by creating an attachment post for holding the information about that media and it's relation (if any) with other post/posts, which ...


0

Some of the code you have in here is really outdated and has been deprecated for quite some time. I am going to use updated code so that it's more useful to those who will stumble on this thread. <div class='news_item'> <?php $posts = get_posts( 'numberposts=2&order=DESC&orderby=post_title&category_name=news' ); ...


0

The function for showing the featured image is http://codex.wordpress.org/Post_Thumbnails To show your content in columns best way would be to wrap your content in a html element then float it. eg. In your template you might have: <?php $posts = get_posts('numberposts=2&order=DESC&orderby=post_title&category_name=news' ); foreach ( ...


1

You can make use of properties on elements. Have a look at the following concept and see if you can use it. You basically hide all "featured" images. Add a general class to the post titles which you want to use to show/hide images. Add a property to the post title element which holds the id of the image you want to show. Generated MarkUp: <img ...


0

Just found this and made it much simpler, works but I'm no security scrubber if(!empty($_FILES)){ require_once( ABSPATH . 'wp-admin/includes/post.php' ); require_once( ABSPATH . 'wp-admin/includes/image.php' ); require_once( ABSPATH . 'wp-admin/includes/file.php' ); require_once( ABSPATH . 'wp-admin/includes/media.php' ); $post_ID = ...


0

This isn't the most elegant answer... but it works! The 'WyPiekacz' plugin, although cool, has not been updated in three years. add_action('transition_post_status', 'check_featured_image_size_after_save', 10, 3); function check_featured_image_size_after_save($new_status, $old_status, $post){ $run_on_statuses = array('publish', 'pending', 'future'); ...


0

I solved the issue as well. With reference to Josh Rodgers' answer, I had to log into my server's CPANEL, under "Software and Services", depending on how your server is set up, there is "Select PHP Version", then tick the "gd" box, save, and refresh your wordpress post or media page, then retry the upload. If you are looking at your wordpress via FTP, you ...


2

You could create a small plugin for this, here is an small example that will try to download and attach a file based on the url in the excerpt field for the post: add_action('publish_post', 'auto_featured_image_publish_post'); function auto_featured_image_publish_post($post, $post_id) { // check if this post is saved for the first time ...


0

<div class="page-section clear"> <div class="single-image-anchor"> <?php if (get_option( 'page_for_posts' ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_option( 'page_for_posts' )), 'single-post-thumbnail' ); ?> <div ...


0

One example is Twenty Fifteen which uses a template tag in the content.php files like this: twentyfifteen_post_thumbnail(); And then the function for the template tag in inc/template-tags.php: if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : /** * Display an optional post thumbnail. * * Wraps the post thumbnail in an anchor element on ...


1

Here's something I wrote because my clients were using very high quality pngs, when they could be more lossy jpgs for web. Note this still preserves the original image, only changes the thumbnails. Add this to your functions.php <?php //Force PNG Thumbnails into JPGs add_filter('wp_generate_attachment_metadata','force_png_to_jpg'); function ...


0

Just to add to this, for anyone else who might need or want the info... You can use the $_wp_additional_image_sizes global to find out if you have any additional image sizes set by theme or any plugins. If these additional images sizes are not needed, you can use remove_image_size($name); function and pass the $name variable from the returned array and ...


1

I figured it out this was a theme option located in the functions.php file set_post_thumbnail_size( 825, 510, true ); This is how this customized size came out in the first place!


1

No need for the filter. You can just call add_image_size later than the parent & it will overwrite.


0

Since you are trying to get the thumbnail within the loop like home page, category page or any other term page. you have to use - the_post_thumbnail(); If you want it in a specific page like single page, you should be using get_post_thumbnail_id($postId);


0

If nothing works, give this a try: $img_attribs = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); // returns an array if( $img_attribs ) { ?> <img src="<?php echo $img_attribs[0]; ?>" width="<?php echo $img_attribs[1]; ?>" height="<?php echo $img_attribs[2]; ?>"> <?php } ?>


0

I had the same problem and I could not make get_the_post_thumbnail() work. However I found a workaround to display the thumbnail on custom type, just adding the code below. <?php echo wp_get_attachment_image( get_post_thumbnail_id(), 'thumbnail' ); ?> Posting in case it may be helpful.


0

You can use 'admin_post_thumbnail_html'. The simple function below will append 'This is a lovely image' to the image returned when you set the post featured image buut since $content is just an HTML string you can manipulate it in any way you want. add_filter( 'admin_post_thumbnail_html', 'my_image_selected', 10, 2 ); function my_image_selected( $content, ...



Top 50 recent answers are included