Forums

Meteor Slides
[resolved] URL does not work due to post_thumbnail_html (4 posts)

  1. JeroenOnstenk
    Member
    Posted 3 months ago #

    HI JLeuze,

    Same as these threads I'm having an issue with your great plugin Meteor Slides and this code

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    	$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
    	return $html;
    };

    Now the solutions given in those threads don't seem to work for me, since I'm using both Meteor Slides and those thumbnails in a custom page, out of the_loop.

    To have the thumbnails shown, I'm using this piece of code

    <?php if ( is_front_page() ) { ?>
       <?php $query = new WP_Query(array('cat'=> '5', 'posts_per_page'=> '10', 'orderby'=>'rand'));
         while ($query->have_posts()) : $query->the_post();
         the_post_thumbnail ('thumbnail');
       endwhile; ?>
    <?php } ?>

    And this code does not allow me to include a workaround like

    <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

    Do you have any other ideas how i could use both Meteor Slides and the clickable thumbnails on one custom page out of the_loop?

    Thanks in advance!

    http://wordpress.org/extend/plugins/meteor-slides/

  2. JLeuze
    Member
    Posted 3 months ago #

    Hi, you can use that same work around, it just needs to be written fully in PHP instead of HTML and PHP to work with your custom loop.

    Remove that filter that is adding the permalink to the post thumbnails, and try updating your loop like this:

    <?php if ( is_front_page() ) {
    
    	$query = new WP_Query( array( 'cat' => 5, 'posts_per_page' => 10, 'orderby' => 'rand' ) );
    	while ( $query->have_posts() ) : $query->the_post();
    		echo '<a href="', the_permalink(), '">', the_post_thumbnail(), '</a>';
    	endwhile;
    
    } ?>
  3. JeroenOnstenk
    Member
    Posted 3 months ago #

    Perfect! Works like a charm!

    Just to have it working completely, i only needed to add 'thumbnail'

    <?php if ( is_front_page() ) {
    
    	$query = new WP_Query( array( 'cat' => 5, 'posts_per_page' => 10, 'orderby' => 'rand' ) );
    	while ( $query->have_posts() ) : $query->the_post();
    		echo '<a href="', the_permalink(), '">', the_post_thumbnail('thumbnail'), '</a>';
    	endwhile;
    } ?>

    Thanks a lot!

  4. JLeuze
    Member
    Posted 3 months ago #

    No problem!

Reply

You must log in to post.

About this Plugin

About this Topic