devpro
@devpro
Учусь...

Как добавить пагинацию в эту функцию HTML карты сайт?

Как добавить пагинацию в эту функцию HTML карты сайт?

/*
    HTML Sitemap
    */
        function get_html_sitemap( $atts ){

                $return = '';
                $args = array('public'=>1);

    // If you would like to ignore some post types just add them to the array below
                $ignoreposttypes = array('attachment', 'reply', 'avia_framework_post');

                $post_types = get_post_types( $args, 'objects' ); 

                foreach ( $post_types as $post_type ) {
                    if( !in_array($post_type->name,$ignoreposttypes)){
                        $return .= '<h2>' . $post_type->labels->name.'</h2>';
                        $args = array(
                            'posts_per_page'   => -1,
                            'post_type'        => $post_type->name,
                            'post_status'      => 'publish',
                            'suppress_filters' => true,
                        );
                        $posts_array = get_posts( $args ); 
                        $return .=  '<ul>';
                        foreach($posts_array as $pst){
                            $return .=  '<li><a href="'.get_permalink($pst->ID).'">'.$pst->post_title.'</a></li>';
                        }
                        $return .=  '</ul>';
                    }
                }

            return $return;
        }
        add_shortcode( 'htmlSitemap', 'get_html_sitemap' );
  • Вопрос задан
  • 37 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы