Last active
April 5, 2016 20:21
-
-
Save scottopolis/c8ba881463245a89bf2ba39e0261c686 to your computer and use it in GitHub Desktop.
Create a custom loop for an AppPresser page
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
/* Custom Loop for a page in an AppPresser app */ | |
function app_custom_loop( $content ) { | |
// edit this with your desired page slug | |
if( is_page( 'featured' ) ) { | |
// add your custom query args here | |
$args = array(); | |
$the_query = new WP_Query( $args ); | |
// The Loop | |
if ( $the_query->have_posts() ) { | |
$content .= '<ul class="list list-full" style="margin:-10px -10px 0 -10px">'; | |
while ( $the_query->have_posts() ) { | |
$the_query->the_post(); | |
$content .= '<li class="post-list-item"><a class="item item-thumbnail-left item-text-wrap" href="' . get_the_permalink() . '">'; | |
$content .= '<img src="' . get_stylesheet_directory_uri() . '/images/thumbnail.jpg">'; | |
$content .= '<div class="item-title">'. get_the_title() .'</div>'; | |
// $content .= '<div class="item-text">' . the_excerpt() . '</div>'; | |
$content .= '</a></li>'; | |
} | |
$content .= '</ul>'; | |
} else { | |
$content .= 'We couldn\'t find anything here, sorry!'; // no posts found | |
} | |
/* Restore original Post Data */ | |
wp_reset_postdata(); | |
} | |
return $content; | |
} | |
add_filter( 'the_content', 'app_custom_loop' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment