lundi 13 février 2017

custom query of custom post type by initial leter

Vote count: 0

What I am trying to do is list a custom post type by the initial letter of the title. I have tried a few code examples but I cant seem to get it to fully function the way I want it. Here is some of the code that I have tried and manipulated to no avail.

PAGE TITLE T

'movies', 'ignore_sticky_posts' => TRUE, 'substring_where' => 'T', ); function restrict_by_first_letter( $where, $qry ) { global $wpdb; $sub = $qry->get('substring_where'); if (!empty($sub)) { $where .= $wpdb->prepare( " AND SUBSTRING( {$wpdb->movies}.movies_title, 1, 1 ) = %s ", $sub ); } return $where; } add_filter( 'movies_where' , 'restrict_by_first_letter', 1 , 2 ); $results = new WP_Query( $args ); ?> request); var_dump(wp_list_pluck($results->movies,'movies_title')); ?>
asked 41 secs ago

Let's block ads! (Why?)



custom query of custom post type by initial leter

Aucun commentaire:

Enregistrer un commentaire