In the category in posts, the picture does not appear

For example, in a post there is a title, a picture, a text, a tag and text…
I choose the category of posts. I don’t see a picture. I see only title and text before the tag .
Why is the picture before the tag is not displayed?

Blog -> Content -> Full Post Content on Index -> “On”. Header, text is available, but no picture.

Hello,

Please, could you provide to us your website link and the WP credentials?

Hi There,

Thank you for writing in, you might have a Custom CSS that hides the feature image on archive pages. Please provide us your site URL so we can take a closer look.

Cheers!

On the main page - ok: https://nyc-brooklyn.ru/

In other categories - does not work. For example here:
https://nyc-brooklyn.ru/category/greencard/
https://nyc-brooklyn.ru/category/reviews/

Hi There,

Thank you for the clarification, this is strange as I do not even see the featured image html markup on archive pages, please do a testing for a plugin conflict. You can do this by deactivating all third party plugins, and seeing if the problem remains. If it’s fixed, you’ll know a plugin caused the problem, and you can narrow down which one by reactivating them one at a time.

Let us know how it goes!

Only these plugins.

Disable Akismet Anti-Spam,All In One SEO Pack, Google XML Sitemaps, WooCommerce - problem still exists

Hi there,

I checked the frontend of your website and could not find the reason why it should not show the images of an archive page. You are using the integrity stack which does have the option to show the images in archive pages as seen in the demo:

http://demo.theme.co/integrity-1/tag/reflective/

Would you please kindly get back to us with the URL/User/Pass of your Wordpress Dashboard using the Secure Note feature of the post to check the admin and look for probable causes regarding this unique behavior on your installation?

Thank you.

Yes, I wrote the login and password in this message.

If you help solve this problem, I will be very grateful.

Hello There,

Thanks for updating in! The archive pages and the blog index needs a featured image. All your post has indeed an image but you have inserted the image within the content and you did not assign a featured image: https://prnt.sc/fwadc0

This is why no image is displaying in archive pages. With your current set up, the images will only display if you enable the “Full Post Content on Index” option. I would recommend that you edit each post and insert a featured image.

I can see that you have 121 posts and editing them one by one is not an option. This would need a custom code that will get the images attached on the post and display it as your featured image. Before you can do that, because what you are trying to accomplish requires a template customization, we would highly to suggest that you use a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please review how we recommend making template changes in Customization Best Practices.

After the child theme is set up, please add the following code in your child theme’s functions.php file

// Custom featured image
// =============================================================================
function x_featured_image( $cropped = '' ) {

  $stack     = x_get_stack();
  $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;

  if ( has_post_thumbnail() ) {

    if ( $cropped == 'cropped' ) {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
      }
    } else {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
      }
    }

    switch ( is_singular() ) {
      case true:
        printf( '<div class="entry-thumb">%s</div>', $thumb );
        break;
      case false:
        printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
          esc_url( get_permalink() ),
          esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
          $thumb
        );
        break;
    }

  } else {
    global $post, $posts;
    $thumb = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $thumb = $matches [1] [0];
    $image = '<img src="' . $thumb . '" class="attachment wp-post-image" alt="">';

    if ( is_singular() ) {
      printf( '<div class="entry-thumb">%s</div>', $image );
    } else {
      printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
        esc_url( get_permalink() ),
        esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
        $image
      );
    }
  }

}
// =============================================================================

Hope this helps. Kindly let us know.

No, the problem is different. On the main page of the blog pictures are displayed: https://nyc-brooklyn.ru/
But the same post does not show a picture in categories, like here: https://nyc-brooklyn.ru/category/reviews/

“Set featured image” is not suitable for me. At the beginning of the article, there are already pictures and text that need to be displayed before the “more” tag.
The text is displayed, but why does not it want pictures.

Perhaps the theme has a function that does not allow you to display pictures in categories. Since it displays the “future image” and so that 2 images in the header do not work, it blocks the picture in the text.

Hi,

Yes that’s correct, as my colleague mentioned the excerpt strips out html tags and images and will show the text only.

The only solution would be to remove the image in your content and set it as a featured image.

Thanks

On the main page everything works.

Does not work in categories, somewhere a bug.

Look here:
https://nyc-brooklyn.ru/page/2/
https://nyc-brooklyn.ru/page/3/
https://nyc-brooklyn.ru/page/4/
https://nyc-brooklyn.ru/page/5/
etc. - Here are the same posts and everything works.

But the same thing does not work in categories:
https://nyc-brooklyn.ru/category/greencard/
https://nyc-brooklyn.ru/category/reviews/
https://nyc-brooklyn.ru/category/blog-usa/
etc.

If I add the featured image, then the design of the page will change. I need like that:
https://nyc-brooklyn.ru/page/2/
https://nyc-brooklyn.ru/page/3/
https://nyc-brooklyn.ru/page/4/
https://nyc-brooklyn.ru/page/5/
Without adding a future picture.

What code needs to be fixed in the theme, so that it shows pictures in categories?

Hello There,

Thanks for updating in! I was in the middle of investigation trying to resolve the issue. Suddenly I was logged out. When I tried to log in again using the code credentials from your previous reply, it is no longer working. Perhaps you have removed username.

Well anyway, to resolve your issue and display image on the category or any archive page, since the child theme is set up, please add the following code in your child theme’s functions.php file

// Custom featured image
// =============================================================================
function x_featured_image( $cropped = '' ) {

  $stack     = x_get_stack();
  $fullwidth = ( in_array( 'x-full-width-active', get_body_class() ) ) ? true : false;

  if ( has_post_thumbnail() ) {

    if ( $cropped == 'cropped' ) {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry-cropped', NULL );
      }
    } else {
      if ( $fullwidth ) {
        $thumb = get_the_post_thumbnail( NULL, 'entry-fullwidth', NULL );
      } else {
        $thumb = get_the_post_thumbnail( NULL, 'entry', NULL );
      }
    }

    switch ( is_singular() ) {
      case true:
        printf( '<div class="entry-thumb">%s</div>', $thumb );
        break;
      case false:
        printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
          esc_url( get_permalink() ),
          esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
          $thumb
        );
        break;
    }

  } else {
    global $post, $posts;
    $thumb = '';
    ob_start();
    ob_end_clean();
    $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
    $thumb = $matches [1] [0];
    $image = '<img src="' . $thumb . '" class="attachment wp-post-image" alt="">';

    if ( is_archive()  ) {
      printf( '<a href="%1$s" class="entry-thumb" title="%2$s">%3$s</a>',
        esc_url( get_permalink() ),
        esc_attr( sprintf( __( 'Permalink to: "%s"', '__x__' ), the_title_attribute( 'echo=0' ) ) ),
        $image
      );
    }
  }

}
// =============================================================================

I have modified this code specifically for your site so that it will display the image in these pages:
https://nyc-brooklyn.ru/category/greencard/
https://nyc-brooklyn.ru/category/reviews/
https://nyc-brooklyn.ru/category/blog-usa/

Please let us know how it goes.

I already wrote above that the display of featured images for my site does not fit. Need to resize the size of the images, since they are stretched to the width. The title is under the picture, etc.

The ideal and easy option for me is that in the category posts with text and picture are displayed before the tag , like in the blog on the main page.

In all themes, it’s true, but in your theme it works only for the main page. In categories, the output of the image to the tag does not work. Text is displayed, but no picture (

If it works on the main, and in other topics - it works. Could you write a code that would do this, like on the main page. Without using featured images.

I can not understand why in your topic, the picture is not shown. There is a title, there is text before the tag , but picture is not display, although there is a picture in the HTML.

Hello There,

Thanks for updating in!

In our theme options, there is a setting that you can display full content index in your blog index or just the excerpts. In the category pages, it will then display the excerpts. This is what is happening. The blog index is displaying full content. The category is displaying the excerpts which is a default in most themes. If you want to display the full content in the category page then please do the following:

1] Using Notepad or TextEdit or Sublime Text or any text editor, please create a new file in your local machine.
2] Insert the following code into that new file

<?php

// =============================================================================
// VIEWS/GLOBAL/_CONTENT.PHP
// -----------------------------------------------------------------------------
// Display of the_excerpt() or the_content() for various entries.
// =============================================================================

$stack                     = x_get_stack();
$is_full_post_content_blog = ( is_home() || is_category() ) && x_get_option( 'x_blog_enable_full_post_content' ) == '1';

?>

<?php

if ( is_singular() || $is_full_post_content_blog ) :
  x_get_view( 'global', '_content', 'the-content' );
  if ( $stack == 'renew' ) :
    x_get_view( 'renew', '_content', 'post-footer' );
  endif;
else :
  x_get_view( 'global', '_content', 'the-excerpt' );
endif;

?>

3] Save the file named as _content.php
4] Upload this file to your server in the child theme’s folder wp-content/themes/x-child/framework/views/global/

To be able to cater this change, you will have to removed the code that I have posted in my previous reply.

Please let us know how it goes.

1 Like

Thank you so much. Everything worked :thumbsup:

1 Like

Glad we could help.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.