Forums

Make default post type hierarchical (5 posts)

  1. kpoelhekke
    Member
    Posted 11 months ago #

    Does anybody know if it's possible to make default posts hierarchical without changing the publication dates? I have a client that filled in > 100 posts but now wants to change the order.

    Thanks in advance!

  2. Peter vanDoorn
    Member
    Posted 11 months ago #

    What do you mean by "hierarchical"? A drop-down menu with sub-menus is "hierarchical". Do you perhaps mean alphabetical?

    If so, you need to modify your WP_Query() to something like this:

    <?php $query = new WP_Query( array ( 'orderby' => 'title', 'order' => 'ASC' ) ); ?>

    If you don't have a WP_Query() in your code, then add it before the line that says <?php if ( have_posts() ) : ?>

    Hope that helps

    Peter

    PS: Here's the reference in the Codex for WP_Query()

  3. kpoelhekke
    Member
    Posted 11 months ago #

    Thanks for the answer peter,

    With hierarchical i mean that posts can be sorted.. For eg custom fieds/taxonomies you can make them hierarchical:

    <?php
    register_taxonomy('genre',array('book'), array(
    'hierarchical' => true, // this makes it hierarchical in the UI
    'labels' => $labels,
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array( 'hierarchical' => true ), // this makes hierarchical URLs
    ));

    I have a plugin that lets you drag and drop hierarchical post types in your preferred order.. I am wondering if this is possible for the default post type also.. :)

  4. Peter vanDoorn
    Member
    Posted 11 months ago #

    Ah, now that I don't know.

    There is a plugin (called Convert Post Types) that will convert posts into custom post types. At least that way you can convert all of your normal posts to custom ones and then have them hierarchical.

    If you go that route, don't forget that you'll need to do a custom WP_Query() each time as the standard query only does regular posts.

    Peter

  5. kpoelhekke
    Member
    Posted 11 months ago #

    Thanks peter! I guess i will use that plugin then :) Great help..

Reply

You must log in to post.

About this Topic