Skip to content

term.posts not sorted by menu_order by default #1917

@hacknug

Description

@hacknug

I'm using Timber::get_terms to get non-empty terms for a given taxonomy. Each one of those terms is correctly sorted (given their menu_order). After looping over this, I need to print the posts using the current term. This is were things don't work as expected.

Somewhat related to #1366 maybe?

Expected behavior

I'd expect work.posts to be returned according to their menu_order just like the default WP_Query would do when using one of these plugins:

Actual behavior

Returned posts are ordered by some other parameter, I guess it must be because the class has some kind of default arguments in case they're not provided.

Steps to reproduce behavior

Here's a simplified version of what I'm doing:

$data['works'] = Timber::get_terms(
	array(
		'taxonomy'   => 'category',
		'hide_empty' => true,
	)
);
{% for work in works %}
    <ol>
        {% for project in work.posts %}
            <li>{{ project.title }}</li>
        {% endfor %}
    </ol>
{% endfor %}

What version of WordPress, PHP and Timber are you using?

WordPress 5.0.3, PHP 7.2, Timber 1.8.4.

How did you install Timber? (for example, from GitHub, Composer/Packagist, WP.org?)

Upgraded to newest version via plugin updater in WordPress dashboard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions