I am looking for a way to add thumbnail images to post Excerpts.
I've installed: SuperSlider-Excerpt and Thumbnail For Excerpts plugins but I need to specifically assign the thumbnail that I want to use per post or automatically get the featured image to display as the thumbnail.
Anyone know a method or plugin that can do this please?
You can do this pretty easily with Wordpress. Like Francy said, the_post_thumbnail() will add the featured image you have picked on the post edit page in the admin section.
First you need to set up your thumbnails in your functions.php file. This is in the root directory of your theme (wp-content/themes/your-theme). Write this:
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200, 200, false ); // Set your size, and clipping options
This would make thumbnails 200x200. You may want something else, so put whatever number you want in there.
Now that thumbnails are active, you can use the the_post_thumbnail() throughout your site, inside the loop, to display the thumbnail you've picked.
For example, if you want them to appear on the index page, head to index.php in your theme root directory, and write , right before . Experiment with where these appear, and get it in the right place for you.
Try within the loop:
the_post_thumbnail("thumbnail");
Or what also helped me was:
<?php
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'thumbnail');
$theImageSource = $image[0];
?>
Related
I currently have featured images set on my child Twenty Twelve theme. I use the featured image as a dynamic header to go at the top of the page when on a post.
However, the featured images I use have text over them so look weird and cut off when put into the excerpt thumbnail in a square format.
Is there a way I can still keep my featured images set, but pull the first content post image and display it as a thumbnail in my excerpts? I have found how to pull the first image across but it displays as a full size image. I really want it to automatically be a 'thumbnail' in terms of dimension and cropping.
Essentially I want to use the 'Easy Add Thumbnail' plugin but this does not work if I already have featured image set...
Help?
You can define a specific image size in your functions.php file using add_image_size(); (http://codex.wordpress.org/Function_Reference/add_image_size);
Essentially you just add this to your functions file....
add_image_size( 'seattle-sized', 420, 420, true );
Then, when calling that first image, you can apply 'seattle-sized' to the image like this...
<?php echo wp_get_attachment_image( 42, 'seattle-sized' ) ?>
The trick is that true at the end of add_image_size, it tells it to crop that bad boy.
Hope this helps!
i am trying to create my first wordpress theme and i came now to a problem i can't seem to solve.
Due to the design of the theme, i would like to have featured images on every post, but they would need to be all the same size.
On my functions.php i have enabled the feature images, set a size and even tried to add custom size, but nothing is working as i wanted.
My code looks like this:
function.php:
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 200,200, true);
add_image_size( 'feat', 200, 200, true );
then on my content.php:
<?php the_post_thumbnail('feat'); ?>
The images resize, but they don't crop. It makes the bigger side of the image equal to 200, but still keeps the original aspect ration.
Any ideas of what i'm doing wrong?
Maybe it happens because you had added add_image_size before you uploaded your images.
Try to delete and upload images again or download Regenerate Thumbnails plugin and regenerate all your images in media library.
I'm trying to show a featured image in Wordpress, I've uploaded the image (put it as the smallest image possible) but when I view the blog list view (category.php) I just get the blog post header, and no image.
Anybody know how to show the image? Checked the source, and doesn't show an image at all.
Hope someone can help, would be much appreciated.
In addition to setting the featured image in WP admin, you need rendering code somewhere in your template files. Something like this:
if ( has_post_thumbnail( get_the_ID() ) ) {
echo get_the_post_thumbnail( get_the_ID() );
}
I use this code in my header.php theme file, but you may prefer it within page.php or elsewhere (category.php seems appropriate in your case).
Check the documentation for help changing the dimensions, adding class attributes, etc. to the <img/> tag generated.
http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail
I would like to add a feature to a WordPress page to display a short list of people, like the one seen here - http://www.blenderbox.com/company/team
I have done this on other sites by styling lists with css. This time however, it's for a client and I can't trust them to copy and paste a <li>, editing the name, job title and img name without messing it up.
What is the best way to go about creating this so that it can be easily reduced/added to in the WordPress dashboard? Basically, so that the user simply clicks "add person" then fills in some fields before updating the page.
I'm new to WordPress (though I understand how it works) but I am competent coding so hopefully an informative nudge in the right direction would be sufficient.
Thanks, Ben.
Use categories. Create a new category called Person or Team or something to that effect. Then use the Post Title for their Name - any other information can be put in the post and then add the image to the Featured Image.
Create a new template for this page by copying over another template file and giving it a header like this to name it.
<?
/*
Template Name: About Us / Team / Whatever
*/
?>
And in the page call only the information you want with something like this:
//Set up the Loop
<?php
global $post;
$args = array (
'category' => 4,
'order' => 'ASC');
$teamposts = get_posts( $args );
foreach( $teamposts as $post ) : setup_postdata($post); ?>
//Call the information you want - put them in <li> if you need
<?php the_title();?>
<?php the_excerpt();?> //OR the_content
<?php the_post_thumbnail('new-image-size');?>
//Close the loop
<?php endforeach; ?>
You can then go on to call anything else you want or run another loop on the same page to call other information.
To get the right sized thumbnail you have called 'new-image-size' - to set this up add a line like this to your functions.php file.
// Post Thumbnails
add_theme_support( 'post-thumbnails' );
// name of the thumbnail, width, height, crop mode
add_image_size( 'front-page-services', 450, 270, true );
Can anyone help me with either disabling the aspect ratio for custom header image cropping in the wordpress 2011 theme, or disabling the cropping altogether?
At this stage I just need to get it done, even if it means modifying the core files. I've googled solutions, but have found none so far.
Thank you!
If I understand well what you want to do, I think you can look at the functions.php file of the theme.
You will see these lines :
// The height and width of your custom header.
// Add a filter to twentyeleven_header_image_width and twentyeleven_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyeleven_header_image_width', 1000 ) );
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyeleven_header_image_height', 288 ) );
// We'll be using post thumbnails for custom header images on posts and pages.
// We want them to be the size of the header image that we just defined
// Larger images will be auto-cropped to fit, smaller ones will be ignored. See header.php.
set_post_thumbnail_size( HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true );
// Add Twenty Eleven's custom image sizes
add_image_size( 'large-feature', HEADER_IMAGE_WIDTH, HEADER_IMAGE_HEIGHT, true ); // Used for large feature (header) images
add_image_size( 'small-feature', 500, 300 ); // Used for featured posts if a large-feature doesn't exist
If you want to change the behaviour of the crop, you just have to set the third parameter of the *add_image_size()* function to false as you can see it in the add_image_size() codex page
I hope that's what you want, if not, let me know ;)