WordPress.org

Ready to get started?Download WordPress

Forums

Auto ThickBox Plus
Adding ?TB_iframe to a php echo call? (3 posts)

  1. niftysmith
    Member
    Posted 1 year ago #

    I've created a custom loop to pull up sub-sites of a travel destination for an educational travel website I'm working on. I'd like to use Auto-Thickbox to pull each sub-site (which are all their own separate custom Post) into an iframe with custom dimensions (1000x500).

    Is this possible?

    If so, here is my loop. I am unsure of how to add the ?TB_iframe to the end of the get_permalink php:

    if ( get_post_meta($post->ID, 'dest_location_ca', true) ) {
         $args = array( 'post_type' => 'sites',
    	'meta_key' => "site_destination",
    	'meta_value'=> "California",
    	'orderby'=> 'title',
    	'order' => 'ASC',
    	'posts_per_page' => 100,
    );
    	$sites = new WP_Query( $args );
    		if ( $sites->have_posts() ) :
    		echo "<h3>California</h3>";
    		while ( $sites->have_posts() ) : $sites->the_post();
    		echo '<ul id="snapshots_list">';
    		echo "<li>";
    		echo "<a href=\"" . get_permalink() ) ."\">";
    		if (has_post_thumbnail()) { the_post_thumbnail('thumbnail', array('class' => 'thumb_destination')); }
    		echo "<br />";
    		the_title();
    		echo "</li>";
    		echo '</ul>';
    
    	endwhile;
    endif;
    }

    Unfortunately, I cannot provide a link to my actual site in progress because we have local test servers that are not accessible outside of the company building. Apologies for that!

    http://wordpress.org/extend/plugins/auto-thickbox-plus/

  2. attosoft
    Member
    Plugin Author

    Posted 1 year ago #

    Hi niftysmith,

    Sorry for this late reply.

    Is this possible?

    I think it is probably possible. Frankly, your code is dirty and has some bugs. Try the following code that I modified, refactored and fixed.

    [ Moderator note: pre works but please use the backtick instead for code. ]

    if ( get_post_meta( $post->ID, 'dest_location_ca', true ) ) {
    	$args = array( 'post_type' => 'sites',
    		'meta_key' => 'site_destination',
    		'meta_value'=> 'California',
    		'orderby'=> 'title',
    		'order' => 'ASC',
    		'posts_per_page' => 100,
    	);
    	$sites = new WP_Query( $args );
    	if ( $sites->have_posts() ) {
    		echo '<h3>California</h3>';
    		while ( $sites->have_posts() ) {
    			$sites->the_post();
    			echo '<code><</code>ul id="snapshots_list">';
    			echo '<code><</code>li>';
    			echo '<code><</code>a href="' . get_permalink() . '?TB_iframe&width=1000&height=500">';
    			if ( has_post_thumbnail() ) {
    				the_post_thumbnail( 'thumbnail', array( 'class' => 'thumb_destination' ) );
    			}
    			echo '<code><</code>br />';
    			the_title();
    			echo '<code><</code>/a>';
    			echo '<code><</code>/li>';
    			echo '<code><</code>/ul>';
    		}
    	}
    }
  3. attosoft
    Member
    Plugin Author

    Posted 1 year ago #

    > Moderator note: pre works but please use the backtick instead for code.

    My code above is rewritten improperly by moderator, so I reposted it.

    if ( get_post_meta( $post->ID, 'dest_location_ca', true ) ) {
    	$args = array( 'post_type' => 'sites',
    		'meta_key' => 'site_destination',
    		'meta_value'=> 'California',
    		'orderby'=> 'title',
    		'order' => 'ASC',
    		'posts_per_page' => 100,
    	);
    	$sites = new WP_Query( $args );
    	if ( $sites->have_posts() ) {
    		echo '<h3>California</h3>';
    		while ( $sites->have_posts() ) {
    			$sites->the_post();
    			echo '<ul id="snapshots_list">';
    			echo '<li>';
    			echo '<a href="' . get_permalink() . '?TB_iframe&width=1000&height=500">';
    			if ( has_post_thumbnail() ) {
    				the_post_thumbnail( 'thumbnail', array( 'class' => 'thumb_destination' ) );
    			}
    			echo '<br />';
    			the_title();
    			echo '</a>';
    			echo '</li>';
    			echo '</ul>';
    		}
    	}
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic