Php 按类别列出自定义发布类型,然后按发布顺序列出

Php 按类别列出自定义发布类型,然后按发布顺序列出,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我真的很感谢你的帮助,因为我对这个循环还不是很有信心。我试图找到一个插件,可以帮助,但似乎没有一个 我需要的是按类别显示自定义帖子类型“从业者”,首先是类别名称:“type”(因此所有完全合格的从业者都会首先显示),然后是标准的帖子顺序(因为客户端希望控制每个类别中从业者的顺序-我正在为此使用插件)。这是显示它的页面: 这是archive-practicer.php文件的代码: <?php get_header(); ?> <h1 class="archiveTitle">

我真的很感谢你的帮助,因为我对这个循环还不是很有信心。我试图找到一个插件,可以帮助,但似乎没有一个

我需要的是按类别显示自定义帖子类型“从业者”,首先是类别名称:“type”(因此所有完全合格的从业者都会首先显示),然后是标准的帖子顺序(因为客户端希望控制每个类别中从业者的顺序-我正在为此使用插件)。这是显示它的页面:

这是archive-practicer.php文件的代码:

<?php get_header(); ?>
<h1 class="archiveTitle">Find A Practitioner</h1>
<div id="main-content">
<div class="container">
    <div id="content-area" class="clearfix">
        <div id="left-area" class="fullwidth practitionerListings">


    <?php



        if ( have_posts() ) :
            while ( have_posts() ) : the_post();
                $post_format = et_pb_post_format(); ?>

                <article id="post-<?php the_ID(); ?>" <?php post_class( 'et_pb_post' ); ?>>

                <div id="practitioners">
                <div id="practitionerName">
                    <h2><?php the_title(); ?></h2>
                    <span class="practitionerType"><?php  $terms = get_the_terms( $post->ID , 'ptype' );
                    foreach ( $terms as $term ) { echo $term->name; }  ?></span>
                    </div>
                <div id="practitionerInfo">
                    <span class="practitionerContact"><?php the_field('contact_details'); ?></span>  
                </div>
                <div id="practitioner-location">
                <?php  $terms = get_the_terms( $post->ID , 'location' );

                foreach ( $terms as $term ) { echo $term->name; }  ?> 
                </div>
            </div>

            <?php
                $thumb = '';

                $width = (int) apply_filters( 'et_pb_index_blog_image_width', 1080 );

                $height = (int) apply_filters( 'et_pb_index_blog_image_height', 675 );
                $classtext = 'et_pb_post_main_image';
                $titletext = get_the_title();
                $thumbnail = get_thumbnail( $width, $height, $classtext, 
$titletext, $titletext, false, 'Blogimage' );
                $thumb = $thumbnail["thumb"];

                et_divi_post_format_content();

                if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) {
                    if ( 'video' === $post_format && false !== ( 
$first_video = et_get_first_video() ) ) :
                        printf(
                            '<div class="et_main_video_container">
                                %1$s
                            </div>',
                            $first_video
                        );
                    elseif ( ! in_array( $post_format, array( 'gallery' ) ) && 'on' === et_get_option( 'divi_thumbnails_index', 'on' ) && '' !== $thumb ) : ?>
                        <a href="<?php the_permalink(); ?>">
                            <?php print_thumbnail( $thumb, 
$thumbnail["use_timthumb"], $titletext, $width, $height ); ?>
                        </a>
                <?php
                    elseif ( 'gallery' === $post_format ) :
                        et_pb_gallery_images();
                    endif;
                } ?>

            <?php if ( ! in_array( $post_format, array( 'link', 'audio', 'quote' ) ) ) : ?>
                <?php if ( ! in_array( $post_format, array( 'link', 'audio' ) ) ) : ?>

                <?php endif; ?>

                <?php


                    if ( 'on' !== et_get_option( 'divi_blog_style', 'false' ) || ( is_search() && ( 'on' === get_post_meta( get_the_ID(), '_et_pb_use_builder', true ) ) ) ) {
                        truncate_post( 270 );
                    } else {
                        the_content();
                    }
                ?>
            <?php endif; ?>

                </article> <!-- .et_pb_post -->
        <?php
                endwhile;



                if ( function_exists( 'wp_pagenavi' ) )
                    wp_pagenavi();
                else
                    get_template_part( 'includes/navigation', 'index' );
            else :
                get_template_part( 'includes/no-results', 'index' );
            endif;

        ?>
        </div> <!-- #left-area -->
    </div> <!-- #content-area -->
</div> <!-- .container -->
</div> <!-- #main-content -->

<?php get_footer(); ?>

找个从业者