Created
November 30, 2010 00:00
-
-
Save jhaus/720868 to your computer and use it in GitHub Desktop.
Creating custom post type template via: http://new2wp.com/pro/wordpress-custom-post-types-object-oriented-series3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$q = new WP_query(); | |
$q->query( 'post_type=site' ); | |
/* Begin the Loop */ | |
if ($q->have_posts()) : | |
while ($q->have_posts()) : $q->the_post(); | |
/** | |
* Now instantiate the Sites class we made in posttypes.php setting the $s variable | |
* Create a new variable $a set to the value of the mshot(250) function from the class. | |
*/ | |
$s = new TypeSites(); | |
$a = $s->mshot(250); | |
/** | |
* Output the content of the Site posts | |
*/ | |
?> | |
<div id="site-<?php the_ID(); ?>" class="sites clearfix user_id_<?php the_author_ID(); ?>"> | |
<div class="site-thumbnail"> | |
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> | |
<?php | |
/** | |
* Here we echo out the value of the $a which is an array. | |
* The [1] will retreive the 2nd value of mshot() which returns the | |
* site thumbnai image which is generated by the Url entered in the post. | |
*/ | |
echo $a[1]; | |
?> | |
</a> | |
</div> | |
<h2 class="site-title"><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h2> | |
<div class="meta"> | |
<?php __( 'Added by: '. the_author_posts_link() .' on '. the_time( "F j" ) .' | '. comments_popup_link( __( "0 Comments" ), __( "1 Comment" ), __( "% Comments" ) ); ?> | |
</div> | |
<div class="entry"> | |
<?php the_content( __( '(More ...)' )); ?> | |
</div> | |
<div class="fl post-tags"><?php the_tags( __( ' ' ), ' , ', ' ' ); ?></div> | |
<div class="fr edit-link"><?php edit_post_link( __( 'Edit' ) ); ?></div> | |
</div> | |
<?php endwhile; ?> | |
<?php if( function_exists( 'wp_pagenavi' )) { wp_pagenavi(); } else { ?> | |
<div class="navigation clearfix"> | |
<div class="alignleft"><?php next_posts_link('« Previous Entries'); ?></div> | |
<div class="alignright"><?php previous_posts_link('Next Entries »'); ?></div> | |
</div> | |
<?php } ?> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment