我有一个模板,有一个专门的工作人员页面。唯一的问题是,我无法重新排列条目。换句话说,所有条目都会根据输入数据的时间自动排序。是否有办法手动更改这些条目的顺序。例如,如果我想在页面上就地上下移动我的秘书。以下是员工页面模板:
<?php if (!defined(\'ABSPATH\')) die(\'No direct access allowed\'); ?>
<?php
/*
Template Name: Staff-Page
*/
get_header();
global $post;
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(array(
\'post_type\' => \'staff-page\',
\'paged\' => $paged,
\'order\' => \'ASC\',
\'posts_per_page\' => 5
));
?>
<ul class="team">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<li>
<div class="four columns">
<div class="bordered">
<figure class="add-border">
<img src="<?php echo ThemeMakersHelper::get_post_featured_image($post->ID, 204, false, 174); ?>" alt="<?php the_title(); ?>" />
</figure>
</div><!--/ .bordered-->
</div><!--/ .four .columns-->
<div class="twelve columns">
<?php $positions = wp_get_post_terms($post->ID, \'position\'); ?>
<h4 class="with-desc" data-desc="( <?php
foreach ($positions as $item)
echo $item->name . \' \';
?>)">
<?php the_title(); ?></h4>
<?php the_content() ?>
<div class="clearfix"></div>
<?php $email = get_post_meta($post->ID, \'staff_email\', true); ?>
<?php if (!empty($email)): ?>
<br />
<a href="mailto:<?php echo $email ?>" class="button default small"><?php _e(\'E-mail\', TMM_THEME_FOLDER_NAME); ?> <?php the_title(); ?></a>
<?php endif; ?>
</div><!--/ .twelve .columns-->
</li>
<?php
endwhile;
endif;
?>
</ul>
<?php get_template_part(\'content\', \'pagenavi\'); ?>
<?php get_footer(); ?>
SO网友:DINESH BHIMANI
按标题降序排列的帖子:这是一种按标题排列帖子以添加标题的格式
query_posts( array( \'category__and\' => array(1,3), \'posts_per_page\' => 2, \'orderby\' => \'title\', \'order\' => \'DESC\' ) );
你的代码需要改变
global $post;
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(array(
\'post_type\' => \'staff-page\',
\'paged\' => $paged,
\'order\' => \'ASC\',
\'orderby\' => \'title\'
\'posts_per_page\' => 5
));
?>
SO网友:Diana Nichols
由于这是一种自定义的帖子类型,最简单的方法就是将“页面属性”添加到您的帖子功能中。然后你可以按你想要的任何方式订购。
在注册帖子类型的数组中添加“页面属性”。示例:\'supports\'=>数组(\'title\',\'editor\',\'page attributes\',\'thumbnail\')
那么您的查询将是:
global $post;
$paged = (get_query_var(\'paged\')) ? get_query_var(\'paged\') : 1;
query_posts(array(
\'post_type\' => \'staff-page\',
\'paged\' => $paged,
\'order\' => \'ASC\',
\'orderby\' => \'menu_order\'
\'posts_per_page\' => 5
));