Last active
January 28, 2018 10:22
-
-
Save jonschr/ed89354301929cfdaf41 to your computer and use it in GitHub Desktop.
An example custom loop page (uses the standard query, but does whatever it wants inside the loop)
This file contains 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 | |
/** | |
* NOTE: We force the full-width content in the functions.php file already; no need to do that here as well. | |
*/ | |
/** | |
* Remove the standard loop | |
*/ | |
remove_action( 'genesis_loop', 'genesis_do_loop' ); | |
/** | |
* Use our loop instead | |
*/ | |
add_action( 'genesis_loop', 'faq_archive_loop' ); | |
/** | |
* The function which will render our custom loop. | |
*/ | |
function faq_archive_loop() { | |
?> | |
<!-- This is a header area that goes above the loop --> | |
<header class="entry-header"> | |
<h1 class="entry-title" itemprop="headline">Frequently Asked Questions</h1> | |
</header> | |
<?php | |
echo '<div id="accordion" class="entry-content faqspage">'; | |
// Starting the loop (using the default query, since we are, after all, in archive-faq.php and it's already correct). | |
if ( have_posts() ) { | |
while ( have_posts() ) { | |
the_post(); | |
?> | |
<!-- This is the content that we're looping through --> | |
<div class="faq-section"> | |
<h3><i class="fa fa-chevron-down"></i><?php the_title(); ?></h3> | |
<div><?php the_content(); ?> | |
<?php | |
if ( current_user_can( 'delete_posts' ) ) | |
edit_post_link(); | |
?> | |
</div> | |
</div> | |
<?php | |
} // end while | |
} // end if | |
echo '</div>'; | |
} | |
/** | |
* This is standard on any Genesis template file. Each file should end with genesis(); (with no closing php tag afterward, because WordPress doesn't like it when you close your php tags at the end of files.) | |
*/ | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment