Wordpress模板部分仅显示帖子类型中选定的帖子

时间:2017-12-17 19:20:23

标签: php wordpress

我有这个模板部分:

Begin Compiling Abaqus/Standard User Subroutines
Sun Dec 17 20:08:48 2017
Compiling std_user.f
Current directory:  /tmp/konrad_std_user_15200
File to compile:    /tmp/konrad_std_user_15200/std_user.f
>>>  gfortran -c -fPIC -I/home/konrad/verify -I. -I/home/konrad/Simulia/solver/linux_a64/code/bin/SMAExternal/pmpi-9.1.2/include std_user.f
End Compiling Abaqus/Standard User Subroutines
Begin Linking Abaqus/Standard User Subroutines
Abaqus Error: The Abaqus user subroutine library could not be found.
This may indicate a problem with the Abaqus installation.
Please contact your system Administrator for further assistance.
Exception:  (<class 'driverExceptions.UserSubroutineLibraryError'>,     UserSubroutineLibraryError(), <traceback object at 0x1b88cf8>)
Traceback (most recent call last):
  File "SMAPyaModules/SMAPyaDriverPy.m/src/driverAnalysis.py", line 201, in run
  File "SMAPyaModules/SMAPyaDriverPy.m/src/driverStandard.py", line 80, in analyze
  File "SMAPyaModules/SMAPyaDriverPy.m/src/driverSharedLibrary.py", line 344, in run
  File "SMAPyaModules/SMAPyaDriverPy.m/src/driverSharedLibrary.py", line 571, in link
UserSubroutineLibraryError
Abaqus/Analysis exited with errors
Running: /home/konrad/Simulia/solver/linux_a64/code/bin/eliT_CheckLicense
Arguments: ['-standard', '-location']
License for standard is available.

我有一个名为食物的邮政类型。我想只显示包含此帖子类型的帖子(标题和整个帖子的帖子)。我应该如何修改模板以使其有效?

1 个答案:

答案 0 :(得分:1)

自定义帖子类型获取查询

<?php  

$custom_args = array(
    'post_type'     => 'food',
    'orderby'       => 'post_date',
    'order'         => 'DESC',
    'post_status'   => 'publish',
    'posts_per_page'=> -1

    );

    $get_news_query = new WP_Query( $custom_args ); ?>

    <?php if ( $get_news_query->have_posts() ) : ?>


        <?php while ( $get_news_query->have_posts() ) : $get_news_query->the_post(); ?>



            <h2><a href="<?php echo get_permalink(); ?>"> <?php the_title(); ?> </a></h2>
            <p><?php the_content(); ?></p>
        <?php endwhile; ?>
    <?php else:  ?>
            <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; 

wp_reset_query();
?>  
相关问题