-
-
Save tommcfarlin/ac5fb77eb3dce5b222e1 to your computer and use it in GitHub Desktop.
[WordPress] An example for how to setup tabbed navigation within a single WordPress template.
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
l<?php | |
/** | |
* Retrieves and creates the HTML used to render the pages for the tabbed navigation | |
* area of the homepage. | |
* | |
* @return The HTML for each of the posts that's rendered in the 'Pages' menu | |
* @package Acme | |
*/ | |
function acme_get_tabbed_content() { | |
$args = array( | |
'post_type' => array( 'page' ), | |
'post__in' => acme_get_homepage_posts(), | |
'post_status' => 'publish', | |
'ignore_sticky_posts' => 1, | |
'orderby' => 'menu_order', | |
'order' => 'asc' | |
); | |
$my_query = new WP_Query( $args ); | |
if ( $my_query->have_posts() ) { | |
$html = ''; | |
while( $my_query->have_posts() ) { | |
$my_query->the_post(); | |
$html .= '<div class="content panel" id="panel2-' . get_the_ID() . '">'; | |
$html .= get_the_content(); | |
$html .= '</div><!-- .content.panel -->'; | |
} | |
wp_reset_postdata(); | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment