upload image only

I edited code if (!function_exists(‘wp_generate_attachment_metadata’)){ require_once(ABSPATH . “wp-admin” . ‘/includes/image.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/file.php’); require_once(ABSPATH . “wp-admin” . ‘/includes/media.php’); } if ($_FILES) { foreach ($_FILES as $file => $array) { $mime = $_FILES[$file][‘type’]; $filesize = $_FILES[$file][‘size’]; $maxsizef = 524288; if($filesize > $maxsizef) $error_array[] = ‘error size, max file size = 500 KB’; if(($mime != … Read more

How do I get only the image URL from the_post_thumbnail()?

You might also try: If you only have one size thumbnail: $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); Or…if you have multiple sizes: $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), “size” ); Note that wp_get_attachment_image_src() returns an array: url, width, height, is_intermediate. So if you just want only the image url: echo $thumbnail[0]; Resources: http://wpcanyon.com/tipsandtricks/get-the-src-attribute-from-wordpress-post-thumbnail/ https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/

add_theme_support post-thumbnails not working

Have a look at this documentation. 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. TRY this add_theme_support( … Read more

How to display featured image description and title?

this might work: $post_thumbnail_id = get_post_thumbnail_id($post->ID); $thumbnail_image = get_posts(array(‘p’ => $post_thumbnail_id, ‘post_type’ => ‘attachment’)); if ($thumbnail_image && isset($thumbnail_image[0])) { $img_description = $thumbnail_image[0]->post_content; $img_caption = $thumbnail_image[0]->post_excerpt; $img_alt = get_post_meta($post_thumbnail_id , ‘_wp_attachment_image_alt’, true); $img_title = $thumbnail_image[0]->post_title; }

Conditional post thumbnail based on logged status and post tag

Hey you have to use the below logic to handle the above conditions, it will work. if (!is_user_logged_in() && has_tag(‘private’)) { ?> <a href=”https://wordpress.stackexchange.com/questions/368246/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”> <img src=”<?php bloginfo(‘template_directory’); ?>/img/default-login.jpg” alt=”<?php the_title(); ?>” /> </a> <?php } else if( is_user_logged_in() && has_tag(‘private’) ) { // show the actual featured image // check … Read more

Recent posts on homepage: different thumbnail based on logged in status and post category

If you want to use the the_ functions (e.g. the_permalink() and the_title()) and including in_category() (without specifying the second parameter) outside of The Loop (the standard one which calls the_post()), you should access the global $post variable and call setup_postdata() to set up global post data and after your foreach ends, call wp_reset_postdata() to restore … Read more

Thumbnail is showing outside its div instead of inside it

the_post_thumbnail() echo the output, hence that’s why the thumbnail is misplaced. To manually echo the output, you should use get_the_post_thumbnail() instead: echo ‘<div class=”post-image right”>’ . // wrapped get_the_post_thumbnail(null, ‘featured-portrait-large’) . ‘</div>’; Or you can instead do this: echo ‘<div class=”post-image right”>’; the_post_thumbnail(‘featured-portrait-large’); echo ‘</div>’;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)