WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Sorting connected post in admin listing (1 post)

  1. ajaxian
    Member
    Posted 5 months ago #

    Hi,

    I have 2 Custom Post Types, in relation one_to_many
    Artist has_many Work and a Work belongs to one Artist.
    My problem is in admin panel, when i list the Works posts.
    I had the artist column but i'am completely unable to sort/order the Work when I click on Artist column.

    add_filter("manage_edit-oeuvre_sortable_columns", 'oeuvres_sort');
    function oeuvres_sort($columns)
    {
    $columns['p2p-to-artist_to_work'] = 'artist';
    return $columns;

    }
    function artist_column_orderby($request)
    {

    if (isset($request['orderby']) && 'artiste' == $request['orderby']) {
    $request = array_merge($request, array(
    'meta_key' => 'artist',
    'connected_direction' => 'to',
    'connected_items' => 'any',
    ));
    }

    return $request;
    }

    add_filter('request', 'artist_`column_orderby');

    I try several things in the artist_column_orderby function but none of them works.

    Do you know how to achieve this ?

    Thank in advance

    https://wordpress.org/plugins/posts-to-posts/

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.