Ethos portfolio gallery image featured post

Hi. I know how the gallery works, to the extent that if I upload a picture, it becomes an attachment to the specific post I was composing when uploading. Or I could also later, go into the media section and attach the specific image I want to a specific post.

However, if I want to do a gallery and I have attached images to a post and one of the images is set to be a “featured image”, then that image doent stay in the gallery in the post.

The work around seem to upload two different images, set one as featured image and one as attachment only, with the other that should be in the gallery. Or you can simply choose not to have a featured image.

I think this solution is bad and I think that all attached images should also be in the gallery.
Is there a code I can add to somehow keep my featured image also in the gallery.
Thanks!!

Hello Kiljian,

Thanks for writing in!

Please keep in mind that the featured image should be attached to the portfolio item so that it will also display in the gallery.

Kindly check out our knowledge base to fully understand how the gallery and the featured image works. You can check it here: https://theme.co/apex/forum/t/features-galleries/100/1

Hope this helps.

Please understand that I have not used the wordpress gallery feature, only your provided portfolio option, to instead of displaying one image, rather display all images that are attached to that post.
This is not the same feature as the wordpress gallery shortcode, please read carefully my posts before writing in.

In Ethos you have made the portfolio posts to either display one image, on the post or a clickable gallery, that is created when images are attached to that post (this is not the easiest way, but its your way).
However, if I have one of the images attached to that post and also as a featured image, that image wont be a part of the gallery. This doesnt make sense.

How can I have the same image in both the gallery and as the featured image.

Hi Kiljan,

Please add this code to your child theme’s functions.php, this should include the featured image

  function x_featured_gallery() {

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

    $args = array(
      'order'          => 'ASC',
      'orderby'        => 'menu_order',
      'post_parent'    => get_the_ID(),
      'post_type'      => 'attachment',
      'post_mime_type' => 'image',
      'post_status'    => null,
      'numberposts'    => -1
    );

    $attachments = get_posts( $args );

    if ( $attachments ) {
      echo '<div class="x-flexslider x-flexslider-featured-gallery man"><ul class="x-slides">';
        foreach ( $attachments as $attachment ) {
          echo '<li class="x-slide">';
            if ( $fullwidth ) {
              echo wp_get_attachment_image( $attachment->ID, 'entry-fullwidth', false, false );
            } else {
              echo wp_get_attachment_image( $attachment->ID, 'entry', false, false );
            }
          echo '</li>';
        }
      echo '</ul></div>';
    }

  }

This should serve as a snippet which we can’t provide further customization.

Hope this helps.

Thank you Rad! You finally understood me. Sometimes its so frustrating to explain yourselfm but you managed to understand me. I’m very happy that it worked.

One, hopefully last question.
Do you know how the attached images are ordered in the galleries?

I have tried all types of settings, names, titles etc, but I dont know how the are ordered.
I thought that it was when they where uploaded, but that is also not the case.
I think it may be a combinations of size (width) and file namne, but I dont know.
Any help with that is highly appreciated.

Hey Kiljan,

It’s ordered by when they’re attached in the post. Regretfully, there’s no easy way to re-order them. You’d need to use a third-party plugin that can control attachments like in this video guide: https://youtu.be/L8giBdYmIT0

Hope that helps.

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