• Resolved ArtGoddess

    (@artgoddess)


    Hello!

    Congratulations for your plugin!

    I kindly ask how can I show an image of the CPT template.

    Image is already uploaded to media gallery, attached (in media gallery), and selected as Featured Image to the CPT.

    Any help would be really appreciated. Many thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TotalPress.org

    (@totalpressorg)

    Hi @artgoddess and thanks for using this plugin ??

    If the post type supports native WordPress thumbnails, on the template creation page as soon as you choose the post type among the first available shorcodes you will find the “thumbnail” one.

    Dont forget to leave your review ??

    Thread Starter ArtGoddess

    (@artgoddess)

    Great! It works. But then the image is inserted without any style.

    And now my question is whether it is possible to use the link with the image block from the Gutenberg editor.

    Many thanks! ????

    • This reply was modified 1 year, 2 months ago by ArtGoddess.
    Plugin Author TotalPress.org

    (@totalpressorg)

    add_filter(‘post_thumbnail_html’, function($html, $post_id, $post_thumbnail_id){
    if(is_singular(‘YOUR_POST_TYPE_KEY’)){
     return wp_get_attachment_url($post_thumbnail_id);
    }
    return $html;
    }, 10, 3);

    Add this code on the functions.php file of your theme/child theme, change YOUR_POST_TYPE_KEY of your template (ex: post, product, ecc).

    Now the shortcode return the image url.

    Let us if it works ??

    Thread Starter ArtGoddess

    (@artgoddess)

    Yes, it returns only the path. But I am not capable to use this path with the Gutenberg image block.

    Any suggestion? Many thanks!

    Thread Starter ArtGoddess

    (@artgoddess)

    I have solved the issue using the “Post Featured Image”, as my Custom Post Types have a Featured Image.

    Thank you again for your support.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Template: add CPT image’ is closed to new replies.