나는 워드 프레스 테마에 어떤 요청을해야했던이 일을 얻기 위해 워드 프레스에서 빌드 기능을 사용할 수 있습니다. 귀하의 경우 (제목을 얻는 것이 태그를 얻는 것보다 쉽게 할 수 있습니다, 예제 링크 에서처럼) 물건을 더 쉽게 할 수 있습니다 (아마).
은 첫째로 당신은 게시물을 얻을 수있는 PHP 페이지를 확인해야합니다. 당신은 아마 알다시피 당신은 독립 PHP 파일에서 WP 물건을 사용할 수 없습니다, 그래서 당신의 파일은 내가 당신을 도우려고 몇 가지 의견을 추가
<?php
// Include the file above for being able to use php stuff
// In my case this file was in a folder inside my theme (my_theme/custom_stuff/get_posts.php).
// According to this file position you can modify below path to achieve wp-blog-header.php from wp root folder
include('../../../../wp-blog-header.php');
// Get all published posts.
$list_posts = get_posts(array('numberposts' => -1));
// Get "q" parameter from plugin
$typing = strtolower($_GET["q"]);
//Save all titles
$list_titles = array();
foreach($list_posts as $post) { $list_titles[] = $post->post_title; }
// To see more about this part check search.php from example
foreach($list_titles as $title) {
if(strpos(strtolower($title), $typing)){
echo $title;
}
}
?>
처럼 보일 것이다 (get_posts.php가 부르 자) 보다 나은.
이제 물건 만 @GBD 많은 감사
$('#yourInput').autocomplete("path_to/get_posts.php");
감사처럼 jQuery 플러그인을 통해 페이지를 호출해야 쉽게 얻을 그러나 나는 내가 원하는 것을 달성하기 위해 쿼리를 수정했습니다. 희망이 다른 사람들을 도울 수 있습니다. ?
get_results ("wp_posts에서 post_title을 선택하십시오 어디에서 post_title LIKE '$ search %'"); foreach ($ search_tags를 $ mytag로) {echo $ mytag-> post_title. ""; }?>'code' –
'code'
@JunaidHassan Ok :) – GBD