[resolved] How add custom filter to admin custom post type pagination? (2 posts)

  1. viter-z-bayraku
    Posted 5 years ago #

    I have select filter in custom post type write panel.
    Post filtered by custom field edate_m:

    add_filter( 'parse_query', 'sort_calendar_by_date' );
    function sort_calendar_by_date($query) {
        global $pagenow;
    if(is_admin() && $pagenow=='edit.php' && isset($_GET['post_type']) && isset($_GET['post_type'])=='calendar' && $_GET['sortby_d'] =='0' && $_GET['sortby_m'] !='0'){
    	        $query->query_vars['meta_key'] = 'edate_m';
    		$query->query_vars['meta_value'] = $_GET['sortby_m'];

    All working perfect. But if I pressing to page 2, filter are resseting and variable &sortby_m=1 in address line in dissapearing.

    How I can implement custom fields filter variable to pagination? Thank you!

  2. viter-z-bayraku
    Posted 5 years ago #

    Sorry! Please delete this topic. I fixed this issue. My code was wrong.
    I deleted line "&& $_GET['sortby_d'] =='0'" and now all working..

Topic Closed

This topic has been closed to new replies.

About this Topic