Add multiple featured images

Hi, I have this need: add multiple featured imges.

I have tried some plugin but without results. Maybe I have not understand to use plugins, the fact is I can’t see the featured images over the stadard one.

Can you help me achieve this result?

Thank you very much

Hello @Ghiotto,

Thanks for asking. :slight_smile:

Setting up multiple featured image is not a default feature offered by X Theme. What you are looking for will require custom development and that falls outside the scope of support we can offer. In case you are not comfortable wit programming, I suggest you to get in touch with a developer.

You can also take a look at following plugin. https://wordpress.org/plugins/multiple-featured-images/

Please note that the plugins I have shared is not a official Themeco advice. It’s just a personal input that I have shared with you to help you get started, it may or may not work. 3rd party plugins may cause some issues and we won’t be able to provide support in that scenario.

Thanks for understanding.

Hi Prasant, I have already try that plugin, but I have used it in a wrong way. Now I have tried again and it works.

But there’s a problem: I would like to view the second featured image under the mastehead of a custom post that I’ve created. I’ve put the output code in the file wp-content/themes/x-child/framework/view/header/masthead.php but nothing is visible.

For a check purpose I’ve tried to put the output code inside another part of theme, i.e. in _header.php after open div #top and here the second featured images is visible.

Maybe musthead.php is not the right file where to put the output code. I would like to show the second fetured image before the </header> closing tag.

The code plugin uses for showing multiple featured images is this: <?php kdmfi_the_featured_image( 'featured-image-2', 'full' ); ?>

I hope you can give me this little help!

Thanks!
Bye

Hi,

To add it below masthead, you can add the code below in your child theme’s functions.php file.

/* ADD CUSTOM FEATURED IMAGE */
function add_my_featured_image() {   
  if(is_singular('post')){
       kdmfi_the_featured_image( 'featured-image-2', 'full' );
  }
}
add_action( 'x_after_view_global__slider-below', 'add_my_featured_image', 10 );

Hope that helps.

Yes, it works like a charme! Thank you very much.

So, for put something below masthead I have always to use x_after_view_global__slider-below, is it correct?

Hello @Ghiotto,

Thanks for updating the thread. :slight_smile:

Yes, you can use x_after_view_global__slider-below to display items below masthead. I suggest you to please take a look at following tutorial for more information on actions and filters available in X and Pro Theme:

Thanks.

Thank you so much!

I have take a look to https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x-pro/208 but there are only a few list of actions of x and pro themes.

For example the x_after_view_global__slider-below is not listed there. Do you have a more comphrensive list of actions and filters?

Thanks

Hi @Ghiotto,

That kind of hook filter is based on template structure, so it’s up to you how you’ll create your own filter. Let’s break that down

x_after_view_global__slider-below

  1. The x_after_view and x_before_view are standard prefix which of course denotes the position (before and after the template call).

  2. The global is the stack folder (eg. global, renew, integrity, icon, ethos),

\framework\views\global\
\framework\views\renew\
\framework\views\integrity\
\framework\views\icon\
\framework\views\ethos\

  1. The _slider-below is the template name (or file name _slider-below.php)

Now combined them but make sure to add _ in between, like x_after_view + _ + global + _ + _slider-below.

As a summary, it will call the function after the template _slider-below.php is called from global views folder. And because _slider-below.php is under the masthead (below), then your code will appear under your masthead too.

Hope this helps :slight_smile:

Yes, it’s very helpful, thank you very much.

I reprise the question of multiple featured images, I know that help on external components is out of your scope. I have try to gain support on plugin suport page, but authors seem to be out of there in these days.

My additional featured image is showing perfectly. I have setup the plugin as explained and I show my additional featured images with this code:

function add_my_featured_image() {   
  if(is_singular('negozi-millennium')){
      kdmfi_the_featured_image( 'featured-image-2', 'full' );
  }
}
add_action( 'x_after_view_global__slider-below', 'add_my_featured_image', 10 );

So, i’ve need to add two extra classes tho this featured image. In the plugin documentation there are not so many explanation about it. https://wordpress.org/plugins/multiple-featured-images/

A part some plugin functions, there’s a list of shortcode arguments that I have thought could be useful to add arguments to kdmfi_the_featured_image function. Then, I have tried to add an argument for new classes, but in this way the featured image is not visible.

I know it can be there some simple solution out there and I know you could know “how to” unlike me :slight_smile:

I hope you can help me. Thank you so much

Hi there,

Unfortunately, this is something you have to get in touch with the Multiple Featured Images plugin developer as what you are trying to do is specific to the plugin function and it is a plugin that we do not have any familiarity about as it is from a third party.

But you could try wrapping the image generated in a div and place the class in the div so you can target the image.

It should be something like:

function add_my_featured_image() {   
  if(is_singular('negozi-millennium')){
      echo '<div class="the-image">';
      kdmfi_the_featured_image( 'featured-image-2', 'full' );
      echo '</div>';
  }
}
add_action( 'x_after_view_global__slider-below', 'add_my_featured_image', 10 );

Thank you for understanding.

Ok, it works very well and, actually, it’s better thant have only a img lost in the html structure of the page. I think a div that wrap the second featured image is generally much better, also for html page syntax.

Thank you very much! :wink:

Perfect!

You’re most welcome. :slight_smile:

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