Highlighted image Wordpress

Asked

Viewed 4,383 times

2

Hello! I am with the following problem, I am building a theme and the page where the posts are added is not the index.php, for the posts to appear I had to put <?php query_posts(''); ?> in the loop, ai worked normally, but the functionality (Highlighted image) that exists in the ADM panel, is gone, but when I activate some other default wordpress theme, this option appears again. Any solution? Thank you!

/* ativa post thumbnails e especifica padrão para tamanho de imagem */ add_theme_support('post-thumbnails'); add_image_size('690x300', 690, 300, True);

  • query_posts() never, ever, fix anything. I swear to you. Trust me or the official documentation: https://developer.wordpress.org/reference/functions/query_posts/. Open another question with the problem you had before, which will certainly be easier to solve.

1 answer

1

Inside your loop, you should call the function the_post_thumbnail_url(). She returns to you the url of the highlighted image of the current post. Here in the documentation you can see more about this function and its variations.

A simple example of using the function:

<div class="blog-post">
    <div>
        <figure>
            <img src="<?php the_post_thumbnail_url(); ?>" alt="<?php echo the_title(); ?>">
        </figure>
    </div>
</div>
  • I’m already using the_post_thumbnail_url(); in the.php loop, and add_theme_support('post-thumbnails'); in Function.php, only, what disappeared was the option (Highlighted image) on the admin panel, just because I’m no longer calling the posts on the main page but on a blog.php in the default wordpress themes this option does not disappear. Image: (http://cdn4.wpbeginner.com/wp-content/uploads/2013/06/setting-featured-image.png)

  • Got it! You’ve already looked at the screen options, if the 'Highlighted image' is set to show?

  • Yes, I’ve looked, just put another theme whatever the posts are being called on index.php reappearing.

  • Could post in the question the codes that you inserted in functions.php?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.