categories - Displaying a Category on a Wordpress Page

I have a game.php file and all main categories are displayed there with a shortcode. output results by category. Questio

I have a game.php file and all main categories are displayed there with a shortcode. output results by category. Question. You don’t need to output in category.php so that I don’t throw it on category.php ... I only need to insert these shortcode that you see below not into the game.php ([main-category]) or category.php files themselves ([child-category]), but in the page. If you insert a shortcode in the game’s page, the main category, that is, everything you need to insert [child-category], if I am transferred to category.php

([main-category]) ([child-category])

front-page.php

    public function get_main_category(){

$arg_cat = array(
    'orderby'      => 'name',
    'order'        => 'ASC',
    'hide_empty'   => 0,
    'exclude'      => '',
    'include'      => '',
    'taxonomy'     => 'category',
    'parent'       => 0,
);
//global $wppb_login;
//if (is_user_logged_in() || isset($wppb_login->ID)){?>




</div>
    <div class="main"><?php
        $all_categories = get_categories($arg_cat);
            $category_link_array = array();
            foreach( $all_categories as $single_cat ){
                $category_link_array[] = '<div class="hexagon" ><div class="wrap"><a href="' . get_category_link($single_cat->term_id) . '">' . $single_cat->name . '</a></div></div>';
            }
            echo implode('', $category_link_array);
        ?>  
    </div> 
    <?php }

category.php

    public function drag_drop_category(){



    function is_subcategory($catid){
        $currentcat = get_category($catid);
        if ($currentcat->parent) {
            return false;
        } else {
            return true;
        }
    }
    ?>

    <body>
    <?php
    $category = get_queried_object();
    $sub_category = get_category(get_query_var('cat'));

    $cat_id = $sub_category->cat_ID;

        if (is_subcategory($sub_category)) {
            ?>
            <div class='parent'>;
                <div class="headline">
                    <h1 style="margin-top: 0"><?php single_cat_title(); ?></h1>
                </div>
                <div class='parent_c'>;
                    <?php
                    if ($category->category_parent == '0') {
                        wp_list_categories(array(
                            'hide_empty' => 0,
                            'child_of' => $category->term_id,
                            'title_li' => __(''),
                        ));
                    }
                    ?> 
                </div>
            </div>
        <?php
        } else {
            $params = array(
                'cat' => $category->term_id,
                'posts_per_page' => -1, 
                'post__in' => get_option('sticky_posts'), 
            );
            $the_query = new WP_Query($params);
            if ($the_query->have_posts()) {
        ?>  
                    <a style=" top:10%;" href="#" onclick="display_hide('#question');return false;">Padomi <i class="fa fa-arrow-down"></i></a>
                    <?php
                    echo "<div class='container-tips'>";
                        echo "<div class='container-question' id='question' style=\"display: none; width: 40%; \">";
                        while ($the_query->have_posts()) : $the_query->the_post();
                            the_title();
                            the_content();
                        endwhile;
                    echo " </div>";
            }
            wp_reset_postdata();
            echo "</div>";
            $query = new WP_Query(array('cat' => $category->term_id,'posts_per_page' => '-1', 'post__not_in' => get_option('sticky_posts'),));
            ?>
            <form id="cardsForm" action="category.php" name="Form" method="post">
                <div class="main">
                    <div class='container-cards' id='drag'>
                        <div class="container-drag">
                            <?php
                            $i = 1;
                            while ($query->have_posts()) {
                                $query->the_post();
                            ?>  

                                <div class="hexagon-cards-drag"  data-type="cards<?php echo $i ?>">
                                    <div class="hexagon-cards-drag-outline"   id="drag<?php echo $i ?>">
                                        <div class="wrap" ><?php echo  get_the_title(); the_content();echo get_the_post_thumbnail( $query-> ID ); ?></div>
                                    </div>
                                </div> 
                            <?php $i++; } ?>
                            <?php wp_reset_postdata();
                            echo '<br >';
                            ?> <h1 class="category_card-title"><?php single_cat_title(); ?></h1>
                                    <div class="hexagon-cards-drag"  data-type="cards-text-1" >
                                        <div class="hexagon-cards-drag-outline"  id="drag-area1">
                                            <div class="wrap"> <textarea name="comment" id='my_textarea' cols="40" rows="3"></textarea></p></div>
                                        </div>
                                    </div> 

                                    <div class="hexagon-cards-drag"  data-type="cards-text-2" >
                                        <div class="hexagon-cards-drag-outline"   id="drag-area2">
                                            <div class="wrap"> <textarea name="comment" id='my_textarea' cols="40" rows="3"></textarea></p></div>
                                        </div>
                                    </div>    

                                    <div class="hexagon-cards-drag"  data-type="cards-text-3" >
                                        <div class="hexagon-cards-drag-outline"  id="drag-area3">
                                            <div class="wrap"> <textarea name="comment" id='my_textarea' cols="40" rows="3"></textarea></p></div>
                                        </div>
                                    </div>    
                        </div>
                    </div>
                </div>
            </form>

            <?php } ?>


</body>

<?php 

} 

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745256448a4618985.html

相关推荐

  • categories - Displaying a Category on a Wordpress Page

    I have a game.php file and all main categories are displayed there with a shortcode. output results by category. Questio

    15小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信