رفتن به مطلب

کار نکردن جستجو در سایت


پست های پیشنهاد شده

سلام دوستان من یک جستجو در سایت گذاشتم برای سایتم اما در سایتم کار نمیکنه ولی در یک سایت ورد پرس دیگه همین فرم کار مییکنه کسی میتونه کمکم کنه.

من محتویات فایل هایم قرار دادم.

این محتویات فایل searchform.phpاست.


<form class="navbar-form navbar-left" role="search" style="margin-top:50px;">
<div class="form-group">
<input type="text" value="<?php echo esc_attr(get_search_query()); ?>" class="form-control col-xs-9" placeholder="جستجو در سایت"/>
</div>
<button type="submit" class="btn btn-default btn-search" value="<?php echo __('Search', THEME_NS); ?>"/>
<span class="glyphicon glyphicon-search"></span></button>
</form>

از این تابع استفاده کردم در قسمت هدر سایتم که منوی سرچ من در هدر سایتم قرار دارد.


<div id="header-search" class="col-lg-6 col-xs-12 col-md-5 col-sm-5">
<?php get_search_form(); ?>
</div>

واین محتویات فایل content-searchاست


<?php
/**
*
* content*.php
*
* The post format template. You can change the structure of your posts or add/remove post elements here.
*
* 'id' - post id
* 'class' - post class
* 'thumbnail' - post icon
* 'title' - post title
* 'before' - post header metadata
* 'content' - post content
* 'after' - post footer metadata
*
* To create a new custom post format template you must create a file "content-YourTemplateName.php"
* Then copy the contents of the existing content.php into your file and edit it the way you want.
*
* Change an existing get_template_part() function as follows:
* get_template_part('content', 'YourTemplateName');
*
*/
global $post;
theme_post_wrapper(
array(
'id' => theme_get_post_id(),
'class' => theme_get_post_class(),
'title' => theme_get_meta_option($post->ID, 'theme_show_post_title') ? '<a href="' . get_permalink($post->ID) . '" rel="bookmark" title="' . strip_tags(get_the_title()) . '">' . get_the_title() . '</a>' : '',
'heading' => theme_get_option('theme_posts_article_title_tag'),
'before' => theme_get_metadata_icons('date,author,edit', 'header'),
'content' => theme_highlight_excerpt(get_search_query(), theme_get_content()),
'after' => theme_get_metadata_icons('category,tag', 'footer')
)
);
?>

اینم محتویات فایل searchاست.


<?php
/**
*
* search.php
*
* The search results template. Used when a search is performed.
*
*/
get_header();
?>

<?php
if (have_posts()) {
theme_post_wrapper(
array('content' => '<h4 class="box-title">' . sprintf(__('Search Results for: %s', THEME_NS), '<span class="search-query-string">' . get_search_query() . '</span>') . '</h4>'
)
);
/* Display navigation to next/previous pages when applicable */
if (theme_get_option('theme_top_posts_navigation')) {
theme_page_navigation();
}
/* Start the Loop */
while (have_posts()) {
the_post();
get_template_part('content', 'search');
}
/* Display navigation to next/previous pages when applicable */
if (theme_get_option('theme_bottom_posts_navigation')) {
theme_page_navigation();
}
} else {
theme_404_content(
array(
'error_title' => __('Nothing Found', THEME_NS),
'error_message' => __('Sorry, but nothing matched your search criteria. Please try again with some different keywords.', THEME_NS)
)
);
}
?>

<?php get_footer(); ?>

لینک به ارسال

نیازی به هیچ کدام از کدهای بالا نیست فقط با این کد تست کنید.


<div id="search">
<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
<div>
<input type="text" size="18" value="<?php echo wp_specialchars($s, 1); ?>" name="s" id="s" placeholder="کلمات کلیدی ..."/>
<input type="submit" id="searchsubmit" value="جستجو" class="submit_input" />
</div>
</form>
</div>

ویرایش شده توسط Rohani
لینک به ارسال

الان در اینجا شما دایرکتوری homeرا فراخوانی کردید من الان برای استفاده ازاین سرچ باید صفحه ای به نام homeدر پوسته سایتم داشته باشم،تفاوت بین صفحه home,indexچی هسته؟

لینک به ارسال

اقای روحانی هم استانی عزیز من تست کردم ک شما را نتیجه جستجوم فقط یک صفحه سفید میاد مطلبی نمایش داده نمیشه و ادرس هم به این شکل در میاد مانند عکس 3ppp_خودسوزی.jpgخب چیزی هست من صفحه homeدر پوسته ام ندارم.

خب حالا بجای صفحه homeمن گذاشتم صفحه indexاما چیزی هست این سرچ براساس کلمات کلیدی برچسب ها کار میکنه نمیشه پیشرفته ترش کرد.ودر صورت مشاهد نشدن مطلبی پیغامی را بده به کاربر.

لینک به ارسال

این search یک مشکل دیگه ای هم داره اینکه وقتی صفحه اصلی بالا میاد هم زمان فرض کنید یک عبارتی را سرچ میکنم که در جزء کلمات کلیدی سایت من نیست خب مطلبی هم بالا نمیاره اما من اومدمعبارتی را سرچ کردم که جزء کلمات کلیدی سایت من بوده مطلب را بالا میاره اما دوباره بیام همان عبارتی را که در ابتدا سرج کردم که جژء کلمات کلیدی مربوطه من نبوده مطلب های مرتبط را بالا میاره.اینجور که من فهمیدم.

لینک به ارسال

به گفتگو بپیوندید

هم اکنون می توانید مطلب خود را ارسال نمایید و بعداً ثبت نام کنید. اگر حساب کاربری دارید، برای ارسال با حساب کاربری خود اکنون وارد شوید .

مهمان
ارسال پاسخ به این موضوع ...

×   شما در حال چسباندن محتوایی با قالب بندی هستید.   حذف قالب بندی

  تنها استفاده از 75 اموجی مجاز می باشد.

×   لینک شما به صورت اتوماتیک جای گذاری شد.   نمایش به صورت لینک

×   محتوای قبلی شما بازگردانی شد.   پاک کردن محتوای ویرایشگر

×   شما مستقیما نمی توانید تصویر خود را قرار دهید. یا آن را اینجا بارگذاری کنید یا از یک URL قرار دهید.

×
×
  • اضافه کردن...