X Theme Replace Featured Image with Gallery [Solved]

I have a custom post type and I want to take out the featured image and use a gallery. Whats the most efficient way of achieving that?

B

Hi there,

Thanks for writing in! Have you tried using the post page using Cornerstone? That way, you will have the control of the page’s layout.

If you created a custom post type, you can enable it on Cornerstone by going to X > Cornerstone > Allowed Post Types then add the post type that you created.

Hope that helps.

Whhaaaat? :slight_smile:

You’re insinuating I can design php layouts to use with CPTs using cornerstone? And not on a post per post basis?

Thanks,
B

Hi There,

Please add the following code under functions.php file locates in your child theme:

function x_featured_image( $cropped = '' ) {

    if(is_singular( 'your-post-type' )){
      /* your gallery code should go here */
    } else {

      $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;
        }

      }
      
    }

}

Then replace /* your gallery code should go here */ with your codes.

Hope it helps :slight_smile:

Using Gallery format built within WP. Wrapping it in ESS Grid. Closing ticket. Thanks again.