如何在相关帖子中显示选择类别的帖子?

时间:2019-04-19 14:57:00

标签: wordpress

Current show related post in post detail. Now i want to show selected category post in related post detail. IN my admin panel show all categories and when selected some category then show selected category post in front.

function ACT_12()
{
	$related_options = get_option( 'related' );
?>
 <div id="second_col" style="float:left; width:80%; display:inline">
        <li id="li_10" style="width:99%" >    
        <span>
        <br />
            <?php ACT_list_categories12(); ?>
        </li>
        </div>
<?php
}
function ACT_list_categories12(){
  $args = array(
    'hide_empty' => '0',
    'child_of' =>  '0'
    );
    $i=0;
    $categories = get_categories($args);
    foreach ($categories as $category) {
        if (!$category->parent) {
            $i++;
          echo ('<input id=cat[] name=cat[] class="element checkbox" type = "checkbox" value="'.$category->term_id.'" />')
echo ('<label class="choice" for=cat[]>'.$category->name.'</label>');
            $i = ACT_get_child_cats( $category->term_id, $i, " ");
   }
    }
    echo ('<input type="hidden" name="total_cats" value="'.$i.'" />');
}
function ACT_get_child_cats($cat, $k, $level)
{
    $next = get_categories('hide_empty=0&parent=' . $cat);
    if ($next) :
        $level .= "&#8212;";
        foreach ($next as $category) :
            $k++;
            echo ('<input id=cat[] name=cat[] class="element checkbox" type = "checkbox" value="'.$category-> term_id.'" />');
            echo ('<label class="choice" for=cat[]> '.$level.' '.$category->name.'</label>');

            $k = ACT_get_child_cats( $category->term_id, $k, $level);
        endforeach;
    endif;	
    return $k;
}
     echo($cat);

当前在帖子中显示相关帖子的详细信息。现在,我想在相关帖子详细信息中显示所选类别的帖子。在我的管理面板中显示所有类别,当选择了某个类别后,则在前面显示所选类别。

0 个答案:

没有答案