Created
October 6, 2010 03:34
-
-
Save hisasann/612770 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Template Name: Recent Entries | |
*/ | |
?><?php | |
// クエリ文字列 | |
$query = $_GET["re"]; | |
// 検索件数 | |
$allsearch =& new WP_Query("s=".$query."&showposts=-1"); | |
// クエリ文字列から記事を検索 | |
query_posts("s=".$query."&showposts=1&orderby=rand"); | |
$title = null; | |
$permalink = null; | |
$count = null; | |
if (have_posts()) : | |
while (have_posts()) : the_post(); | |
$convmap = array(0x0, 0x2FFFF, 0, 0xFFFF); | |
// 実体参照をデコード | |
$title = mb_decode_numericentity(get_the_title(), $convmap, 'UTF-8'); | |
$permalink = get_permalink(); | |
$count = $allsearch->post_count; | |
endwhile; | |
else : | |
$title = "検索結果がありませんでした。"; | |
endif; | |
echo json_encode(array("title"=>$title, "permalink"=>$permalink, "count"=>$count)); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment