Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1377446
    arjunaghose22
    Participant

    Can someone please tell me how i can get the caption for a featured image to display (i.e. print) on the webpage in the Integrity stack?

    #1377733
    Lely
    Moderator

    Hi There,

    Because this requires a template change, I’d advise that you setup 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.

    Then add the following code on your child theme’s functions.php file:

      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 );
    		  printf( '<div class="entry-caption">%s</div>', the_post_thumbnail_caption() );
              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;
          }
    
        }
    
      }

    *Note: we have added this line of code:
    printf( '<div class="entry-caption">%s</div>', the_post_thumbnail_caption() );
    The original function code is on this file:\wp-content\themes\x\framework\functions\global\featured.php

    Hope this helps.

    #1378528
    arjunaghose22
    Participant

    That’s great. I will do that. Thank you so much for your help.

    #1378583
    Joao
    Moderator

    Glad to hear it,

    Cheers

    #1384620
    arjunaghose22
    Participant

    Thanks, that works perfectly. Thanks so much for your help. Great service and theme you have here.

    #1384688
    Joao
    Moderator

    🙂 awesome!

  • <script> jQuery(function($){ $("#no-reply-1377446 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>