• Resolved edzio

    (@edzio)


    Is it possible to have the posts be ordered by the same order they are written within the shortcode?

    For example, right now I have [ic_add_posts ids=’609,612,616,578,713,352′] and I wish for the post output to being at 609 and go through the order I have put it in ending with 352.

    Currently it only sorts by ASC or DESC which messes the orders all up and it is very important for me to have the ability to specify my post order in a specific way.

    Thanks for any help!

    http://wordpress.org/plugins/posts-in-page/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi edzio,

    Sorry, it won’t work that way 🙁 You need to use the same Order and Orderby parameters that are available for wp_query http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    Probably the easiest way to do what you want to do would be to create a custom field called ‘postorder’ and use numbers as values for each of your posts (1, 2, 3, 4, etc).

    Then you could use this shortcode:

    [ic_add_posts meta_key=’postorder’ orderby=’meta_value_num’ order=’ASC’]

    Hope that helps.

    Anne

    Thread Starter edzio

    (@edzio)

    Thanks for the reply, I found another solution. This does modify the core of the plugin so anyone doing this should take note that the change will be lost if they upgrade the plugin at a future date.

    SImply change the following lines in the page_posts.php file (found in the lib folder).

    Remove the order line and then change orderby to

    ‘orderby’ => ‘post__in’,

    This will output all posts in the order they were entered in the short code

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Order by ID's in short code?’ is closed to new replies.