WordPress.org

Ready to get started?Download WordPress

Forums

Flexible Posts Widget
[resolved] Fixed order of posts (8 posts)

  1. cinus89
    Member
    Posted 5 months ago #

    Is possible to set the fixed order of posts? If not, what should I edit to do this?

    https://wordpress.org/plugins/flexible-posts-widget/

  2. DaveE
    Member
    Plugin Author

    Posted 5 months ago #

    Hi cinus, I don't understand your question. Each widget has settings for the order of posts, yes. I don't understand what you mean by "fixed." Can you clarify?

  3. cinus89
    Member
    Posted 5 months ago #

    For example: I want to show post id 78 on the first place, post id 23 on the second and post id 221 as last one.

  4. DaveE
    Member
    Plugin Author

    Posted 5 months ago #

    Yes, this is possible using the ID tab to select the posts you'd like to show, in the order you'd like them to appear. Cheers!

  5. cinus89
    Member
    Posted 5 months ago #

    What should I select in the order form?

  6. DaveE
    Member
    Plugin Author

    Posted 5 months ago #

    Ah, you are right. Ordering is still applied when you get posts by ID, but there is no option to show them in the order you specific on the ID tab. So the current, correct answer to your original question is actually, no, you can't set a "custom" order within the widget.

    Sorry, I I've never even considered this scenario until you brought it up today. Right now you could filter the FPW query args (using the dpe_fpw_args filter) and set the orderby to post__in per the Codex.

    The difficultly with this is you'd only want to filter the one instance of the widget that is using the get posts by ID tab. It would look something like this (not tested):

    function dpe_filter_fpw_pid_ordering( $args ) {
    	if( isset( $args['post__in'] ) ) {
    		$args['orderby'] = 'post__in';
    	}
    	return $args;
    }
    add_filter( 'dpe_fpw_args', 'dpe_filter_fpw_pid_ordering' );

    I'll add this functionality to the next release of the plugin. Thanks for point it out!

  7. cinus89
    Member
    Posted 5 months ago #

    Yes, that's it! Thanks a lot :) It's nice functionality.

  8. DaveE
    Member
    Plugin Author

    Posted 4 months ago #

    Hi Cinus,

    Just a heads up that version 3.9 includes an option to sort by Post ID Order natively. You can set your widget instances to use this option and safely remove the custom filter.

    Cheers!

Reply

You must log in to post.

About this Plugin

About this Topic