Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

In the custom part, get in the index of the current item

$
0
0

Replies: 0

Hi,

I am looking for a way to get the current index of the item displayed in the custom parts/wp-instagram-widget.php.

I need this index, because the HTMl will change depending the current item number (custom grid…)

Ideally I would need something like:

$index = 0;
foreach( $media_array as $item ) {
  if ( locate_template( $template_part ) !== '' ) {
    include locate_template( $template_part );
  } else {
    echo blabla
  }
$index++;
}

or maybe even simpe with

foreach( $media_array as $key => $item ) {
  if ( locate_template( $template_part ) !== '' ) {
    include locate_template( $template_part );
  } else {
    echo blabla
  }
}
  • This topic was modified 12 minutes ago by anakaotheme.
  • This topic was modified 9 minutes ago by anakaotheme.

Viewing all articles
Browse latest Browse all 59525

Trending Articles