WordPress - Missing Featured Image Thumbnail in Posts Page - wordpress

I added a featured image to my custom post type and it appears correctly on the front-end, but on the custom post type the featured image thumbnail doesn't show up at all.
As you can see, the Remove featured image button is read, but the thumbnail is not available. I used the_post_thumbnail() in my PHP code to display the featured image, which works correctly, but I don't know why the thumbnail missing. Anyone know why this is happening?
Thanks!

just add below code to your active theme's function.php
add_action( 'after_setup_theme', 'custom_featured_image_backend' );
function custom_featured_image_backend() {
add_theme_support( 'post-thumbnails','your_custom_post_type_name');
}

Related

How to force WordPress Gutenberg to update the featured image after saving the post?

I am working on a plugin that automatically attaches a featured image to a WordPress post after save (i.e. programmatically not using the Media Selector). The plugin uses the add_action( 'save_post_post', 'myFunction'); hook to save the image to the post.
The Gutenberg UI does not update the featured image thumbnail in the metabox on the right column.
I have tested and verified that the image is successfully updated and attached to the post, and does show if you manually reload the page.
From what I can tell, I need to tell Gutenberg the featured image has been changed in order for it to be updated in the view.
I have been unable to locate a hook or action I can use to trigger such a refresh after the user presses the "Save" button.
What is the appropriate way accomplish this refresh (from within my plugin PHP file)?
The way I see it, WordPress takes care of the update for you. Maybe you didn't use the right hook?
When I use the following, my posts have a default thumbnail, whenever I open a new plugin page:
function custom_add_thumbnail( $post_ID ) {
set_post_thumbnail($post_ID, 67);
return $post_ID;
}
add_action( 'save_post', 'custom_add_thumbnail' );
If this doesn't help, please share your code, maybe in pastebin, so I can investigate further.

Woocommerce add click to enlarge under featured image

I'm using Woocomerce (Wootique) and I'd like to add "Click To Enlarge Image" beneath the featured image on single product page. Text should show beneath image and above the description/reviews tabs.
Can't figure it out? Any ideas?
http://www.forgottentreasurez.us/product/hand-signed-limited-edition-serigraph-mazal-tov-love/
Thank you in advance
There’s an action that you can use to add content below featured images, which can be used before or after product thumbnails. The woocommerce_product_thumbnail action is what will help us out. Let’s add a notice that says, “Click to Enlarge” below the featured image.
We’ll use a function to insert this text as a heading below the featured image. You can add this to your child theme or, even better, a code snippet using the Code Snippet plugin.
function skyverge_add_below_featured_image() {
echo '<h4 style="text-align:center;margin-top:10px;">Click to Enlarge</h4>';
}
add_action( 'woocommerce_product_thumbnails' , 'skyverge_add_below_featured_image', 9 );

Limit number of images in a nextgen gallery

I am using the nextgen gallery plugin for WordPress. I am making a page in which I want to get the nextgen gallery by id and limit the number of images in it to 2. The code I am using to get the gallery is:
$post_id = get_the_ID();
$gallery = get_post_meta (get_the_ID(), 'Gallery', false);
$successes = $gallery[0]; /* Where $array is the variable holding the result */
$gallery_id= $successes[0];
echo do_shortcode('[nggallery id='.$gallery_id.']');
There are six images in the gallery and they are used in the original post. This is just a tour post so I want to limit the number of pictures here. Is this possible?
You can try the following shortcodes:
1.
echo do_shortcode("[nggallery id=$gallery_id images=2]");
the images parameter controls the number of displayed images. 0 means show all. You will also get some pagination links to navigate through gallery's images. I haven't found an option to hide them, so if they are unnecessary you can hide them via css (display: none).
2.
echo do_shortcode("[random max=2 id=$gallery_id]");
which displays randomly maximum 2 pictures from your gallery.
I also recommend the following links:
NextGEN Gallery Shortcodes, var 2.0 and up:
http://www.nextgen-gallery.com/nextgen-gallery-shortcodes/
NextGEN Legacy Shortcodes:
http://www.nextgen-gallery.com/help/shortcodes/
Undocumented NextGEN Gallery shortcodes:
http://www.ralph-kemps.eu/2013/03/19/undocumented-nextgen-gallery-shortcodes/

Setting thumbnail featured image size not working properly

Hi I just started today on creating my first Wordpress Theme and I am trying to create a featured Image for each post.Aldo I have managed to acomplish that it seems that the sizes I am giving it are not taking effect.Here is my code:
if(function_exists('add_theme_support')){
add_theme_support('post-thumbnails' , array('post'));
set_post_thumbnail_size(200,120);
}
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
It seems that my featured images are not always set to the same size.For example if the image is smaller then what size I set it will remain the same , for big images the width is the same but for some the height is different.
What am I doing wrong here?
Are you setting the thumbnail size in functions.php? It will not work properly if it's just in index.php or another theme file.
From the codex:
This feature must be called before the init hook is fired. That means
it needs to be placed directly into functions.php or within a function
attached to the 'after_setup_theme' hook. For custom post types, you
can also add post thumbnails using the register_post_type function as
well.
the_post_thumbnail() displays the thumbnail and should be placed where you want the thumbnail to display.

How to change default post attributes?

My site needs to have image based posts, meaning the post is only an image.
Now i tried implementing it with Custom Post Types, but have encoutred problems,
like categories didn't show the right posts, pagination caused problems etc.
Now i thought to myself that i don't need the regular posts and if i could just edit them
to have only the featured image option enabled, life would be much easier.
But i failed to find any information regarding this.
Anyone can help me please?
To add featured image support/option simply add the following code snippet to your functions.php file located inside your theme's root folder
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
}
and to show the featured image inside your template you can do
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail(); // will show the featured image if you have set any for the post
}
Applicable to Wordpress version-2.9 and higher.
When you add new post just find the featured image meta box and set an featured image from there.
You can also setup image sizes (depending on that images will be displayed) at the front end, just take a look at here.

Resources