로 시작하는 글을 보여 어떤 문자를 추가
<?php
add_action('posts_where', 'startswithaction');
function startswithaction($sql){
global $wpdb;
$startswith = get_query_var('startswith');
if($startswith){
$sql .= $wpdb->prepare(" AND $wpdb->posts.post_title LIKE %s ", $startswith.'%');
}
return $sql;
}
add_action('posts_where', 'startswithnumberaction');
function startswithnumberaction($sql){
global $wpdb;
$startswithnumber = get_query_var('startswithnumber');
if($startswithnumber){
$sql .= $wpdb->prepare(" AND $wpdb->posts.post_title NOT REGEXP %s ", '^[[:alpha:]]');
}
return $sql;
}
query_posts($query_string .'&startswith='.$_GET['letter'].'&posts_per_page=-1&startswithnumber='.$_GET['number']);
?>
</code>
및 U는이 편지로 시작하는 검색 결과가 게시물에 필터링됩니다 어떤 문자를 클릭하면 그와 같은
echo "<a href='$PHP_Self/?$query_string&number=true' ># </a> - ";
foreach (range('A', 'Z') as $i)
{
$letter =strtolower($i);
echo "<a href='$PHP_Self/?$query_string&letter=$letter' >$i </a> - ";
}
echo "<a href='$PHP_Self/?$query_string' >All </a>
귀하의 링크를 추가