Add “Featured Image” box in my plugin post page

You can add that featured image metabox you’ve circled to your custom post type by doing: register_post_type( ‘yourCPTslug’, [ //… ‘supports’ => [‘title’, ‘editor’, ‘thumbnail’] // note: thumbnail ] ); add_action( ‘after_setup_theme’, function () { add_theme_support( ‘post-thumbnails’ , [‘yourCPTslug’] ); }); As for a single function calling it in a position where you want it … Read more

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/