Skip to content

Instantly share code, notes, and snippets.

@celticwebdesign
Created April 15, 2016 13:21
Show Gist options
  • Save celticwebdesign/18c9efc95226e34586d7ed1febe84ac6 to your computer and use it in GitHub Desktop.
Save celticwebdesign/18c9efc95226e34586d7ed1febe84ac6 to your computer and use it in GitHub Desktop.
WordPress adjust loop query - used on FHC search.php
<?php
global $query_string;
query_posts($query_string . "&post_type=document");
?>
<?php if (have_posts()): while (have_posts()) : the_post(); ?>
<!-- article -->
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<!-- post title -->
<h3>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h3>
<!-- /post title -->
<!-- post details -->
<div class="meta-data">
<div class="date">
<?php
echo get_the_time('F jS')." ";
echo "<span class='year'>".get_the_time('Y')."</span>";
?>
</div>
<div class="author">
<?php _e( 'Writer: ', 'html5blank' ); ?> <?php echo get_the_author(); ?>
</div>
<?php the_image_credits(); ?>
</div>
<!-- /post details -->
<?php
// $examplePost = get_post();
// echo $examplePost->ID; // Display the post's ID
// echo "<pre>";
// print_r($examplePost);
// echo "</pre>";
?>
<?php html5wp_excerpt('html5wp_index'); // Build your custom callback length in functions.php ?>
<?php edit_post_link(); ?>
</article>
<!-- /article -->
<?php endwhile; ?>
<?php else: ?>
<!-- article -->
<article>
<h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
</article>
<!-- /article -->
<?php endif; ?>
<?php wp_reset_query(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment