Created
August 28, 2015 10:09
-
-
Save mohsinrasool/aff776c19753074727b0 to your computer and use it in GitHub Desktop.
Wikis listing for WPMU Dev Wiki Plugin
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
add_shortcode('wiki_page','my_wiki_page'); | |
function my_wiki_page($atts, $content) { | |
ob_start(); | |
$post_type = 'incsub_wiki'; | |
// Gets every "category" (term) in this taxonomy to get the respective posts | |
//$terms = get_terms( 'wiki_category' ); | |
$mainWikis = new WP_Query(array( | |
'post_parent' => 0, | |
'post_type' => 'incsub_wiki', | |
'numberposts' => 100000 | |
)); | |
$i =0 ; | |
?> | |
<div id="wiki_category_list" class="item-list"> | |
<div class="row"> | |
<?php | |
while( $mainWikis->have_posts()) { | |
$mainWikis->the_post(); | |
echo '<div class="col-sm-6"><div class="item"><div class="row"><div class="col-sm-4">'; | |
if(has_post_thumbnail()) | |
the_post_thumbnail(); | |
echo '</div><div class="col-sm-8"><h2>'.get_the_title().'</h2>'; | |
$children = get_posts(array( | |
'post_parent' => get_the_ID(), | |
'post_type' => 'incsub_wiki', | |
'numberposts' => 5 | |
)); | |
if(count($children)) { | |
echo '<ul>'; | |
foreach($children as $child) { | |
echo '<li><a href="'.get_permalink($child->ID).'" class="incsub_wiki_crumbs">'.$child->post_title.'</a></li>'; | |
} | |
echo '</ul>'; | |
} | |
else | |
echo '<p>No wikis</p><br/><br/>'; | |
echo '<a class="button" href="'.get_permalink(get_the_ID()).'">View All</a>'; | |
echo '<a class="button" href="'.get_permalink(get_the_ID()).'?action=edit&eaction=create" style="margin-left: 10px;">Create New</a>'; | |
echo '</div></div></div></div>'; | |
if(++$i%2 == 0) | |
echo '</div><div class="row">'; | |
} | |
if($i%2 != 0) | |
echo '</div>'; | |
echo '</div>'; | |
return do_shortcode(ob_get_clean()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment