• How do I go about using featured images with pages rather than posts? Is it even possible?

    I’ve already been using them with posts, but can’t figure out how to use them on pages as well.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Take a look through all the ‘images’ plugins in the WP repository. Many of them allow you to put images wherever you wish.

    Got exactly same problem.
    WP docs say that thumbnails can be enabled for post and/or for pages(!):

    https://codex.www.ads-software.com/Function_Reference/add_theme_support#Post_Thumbnails

    But only there. On all other places only posts are mentioned ?!?

    Also, when I enable thumbnails for pages I can select one for every page.
    It works well in admin part. But in template I can’t picture I uploaded with the_post_thumbnail() ?!?
    Also for that function docs says that it must be inside loop?!? Why if I’m using thumbnail attached to page, not to post.

    I’m new to WP, but constantly I’m finding some illogical docs, examples…

    Please, help, advice.

    pages and posts use loops….

    add theme support for post thumbnail makes it work so you can upload the thumbnail

    but each template you want thumbnails displayed on must call the_post_thumbnail to display the images

    page.php for pages
    index.php for index/blog list view
    single.php for single post view
    etc…

    Thanks RVoodoo for your reply,

    Yes, I added theme support and I can upload thumbnail for every page. That works fine.

    But “the_post_thumbnail()” is not outputting anything?
    I’m just putting that function call in header template (because every page have some picture) at place where I want page photo to appears – is that enough?
    Do I have to put it inside of some kind of loop? I mean I’m showing one page in a time and I got one thumbnail for a page, so I don’t understand what can I loop here?

    the_post_thumbnail() has to go inside the loop of the page you want it to appear, not in header.php (because it is not a post)

    the loop still exists in page.php

    It starts at if have posts while have posts line,

    and ends at the endwhile endif

    so your the_post_thumbnail code goes in between there

    If you want to display thumbnails in the header, you will need to figure out a way to call them…. probably using a little mini loop
    https://codex.www.ads-software.com/The_Loop

    Primoz

    (@primoz-frelih)

    Hi, find and add this to your “add_theme_support” function in functions.php:

    add_theme_support( ‘post-thumbnails’, array( ‘post’, ‘page’ ) );

    It’s also useful for the custom type posts, just add them to the array.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Add a featured image to a PAGE rather than post’ is closed to new replies.