• I’ve spent the last 3 days trying to figure this out but I cant. Part of the reason is that I am not sure what to research and how it should be done. If someone could point me in the right direction It would be a great help.

    I need to filter the next and previous_post_links first by custom post type and then by key value.

    Basically, I have an events page using a custom post type and i’m using a date picker to set key values. When a person selects a single event I want them to be able to use the previous and next links to click through the events for that day.

    I was thinking that I could just do a custom wp_query . However, the links are never reflecting the query I do.

    Then I saw a post on stackoverflow using filters. However, I couldn’t get this to work for my situation.

    I’m not asking for someone to show me code. If you could just let me know if this can be done and tell me what I need to be researching on Google. I’ve seen a lot of posts, but nothing quite like what I am needing.

    Thanks!

    Thanks!

Viewing 1 replies (of 1 total)
  • I have used filters like that shown below to have previous/next_post_link show posts by the same author. I think the technique would work for you.

    Before calling previous/next_post_link(), I set a global with the author id. This activated the filters to add to the WHERE clause in the query. I set the global to false after the calls to deactivate the filters.

    function mam_get_next_post_where_filter ( $where, $in_same_cat = false, $excluded_categories = '' ) {
       global $mam_global_authid, $wpdb;
       if ($mam_global_authid) $where .= "  AND p.post_author = $mam_global_authid";
       return $where;
    }
    add_filter('get_next_post_where','mam_get_next_post_where_filter');
Viewing 1 replies (of 1 total)
  • The topic ‘Filtering next_post_link and previous_post_links..’ is closed to new replies.