Support » Fixing WordPress » Use get_adjacent_post() with meta query?

  • Hi,

    I’d like to use get_adjacent_post(); on my single-project.php (custom ‘project’ post type), but only filtering posts that have a meta_key ‘_project_type_type’ with value ‘normal’.

    I had a look at the code of this WP function and noticed that filters can be applied to the SQL query before it’s run:

    $where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );

    .. but unfortunately my SQL skills are bad, so I don’t really know how to mix my meta_query need with this filter. I feel it can be ‘easily’ done, but can’t get my hand on the correct syntax to do it. Anyone out there that had to do the same? That’ll be greatly appreciated 😉

    BTW, just to clarify… My get_posts(); based on the meta_query I just described looks like:

    'meta_query' => array( array('key' => '_project_type_type', 'value' => 'normal') )


  • The topic ‘Use get_adjacent_post() with meta query?’ is closed to new replies.