Change Wiki Archive page to list only parent wikis
-
I wanted to change the archive page to display only the parent Wikis. The archive page displays when you go to the wiki slug (default is /wiki). Figured out this code so thought I would share. Place this code in a file named archive-incsub_wiki.php and place the php file in your theme folder:
<?php //Place this php file in theme folder $wiki_id = wiki; //Get the wiki you specify, for the root use the wiki slug you set in wiki settings, default is wiki $post = get_post($wiki_id); //Getting the posts by wiki id setup_postdata($post); //Sets up global post data and helps to format custom query results for using Template tags get_header(); ?> <div id="primary" class="site-content"> <div id="content" role="main"> <h1 style="text-decoration: underline;">MY WIKI TITLE</h1> <!-- Display this text as title --> </br> <!-- Add a line between the title and Wiki titles --> <?php if ( ( have_posts() ) //Check to see if there are any Wikis && ( 0 == $post->post_parent ) ) { //If yes then only get the parent posts ?><a href="<?php the_permalink(); ?>"><?php the_title( '<h3>', '</h3>' ); ?></a><? //Display the parent post title as a h3 styled hyperlink } else { //If no Wikis are found print this message on the screen echo "No Wikis found, please go add some"; } ?> </div><!-- #content --> </div><!-- #primary --> <?php get_sidebar(); ?> <?php get_footer();
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Change Wiki Archive page to list only parent wikis’ is closed to new replies.