0

I have a template that has a dedicated page for STAFF. The only problem is, I can't rearrange the entries. In other words, all the entries are automatically sorted based on time when the data was entered. Is there a way to manually change the order of these entries. For example, if I want to move my secretary on spot up or down on the page. Here is the staff page template:

<?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(); ?>
  • 1
    Please format your code properly so other could easily read it. – Nilambar Sharma Oct 15 '14 at 11:59
0

posts, in descending order by the title: this is a format of post order by it's title to add title

query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC' ) );

And it's your code want change

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
));
?>
0

Since this is a custom post type, the simplest thing would be to add "page-attributes" to your post capabilities. Then you can order them any way you want.

  1. Add 'page-attributes' to the array where you register the post type. example: 'supports' => array( 'title', 'editor' , 'page-attributes', 'thumbnail' )

  2. Then your query would be:

    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
    ));
    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.