مشکل در کد php
سلام وقت بخیر
آقا این افزونه ما مشکلش چی هست که توی وردپرس نمایش داده نمیشه
https://uploadkon.ir/uploads/dd4214_23custom-word-database.rar
این فایل افزونه
و این کدها
<?php
/*
Plugin Name: پایگاه داده کلمات سفارشی
Description: افزونهای برای جستجو در دیتابیس کلمات و نمایش نتایج.
*/
// خواندن فایل کلمات و ایجاد آرایه از آن
function custom_read_words_from_file() {
$file_path = plugin_dir_path(__FILE__) . ‘words.txt’; // مسیر فایل کلمات
if (file_exists($file_path)) {
$words = file($file_path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
return $words;
}
return array();
}
// نمایش نتایج جستجو با شورتکد
function custom_search_results_shortcode($atts) {
if (is_search()) {
$atts = shortcode_atts(array(
‘title’ => ‘نتایج جستجو’,
), $atts);
$search_terms = get_search_query();
$words = custom_read_words_from_file();
$matched_words = array();
foreach ($words as $word) {
if (stripos($word, $search_terms) !== false) {
$matched_words[] = $word;
}
}
if (!empty($matched_words)) {
$output = ‘<h2>’ . esc_html($atts[‘title’]) . ‘: ‘ . esc_html($search_terms) . ‘</h2>’;
$output .= ‘<ul>’;
foreach ($matched_words as $matched_word) {
$output .= ‘<li>’ . esc_html($matched_word) . ‘</li>’;
}
$output .= ‘</ul>’;
} else {
$output = ‘<p>متاسفانه نتایجی یافت نشد.</p>’;
}
return $output;
}
}
add_shortcode(‘custom_search_results’, ‘custom_search_results_shortcode’);
بعد گذاشتن شورتکد در مطلب چیزی نمایش داده نمیشه
ارسال یک پاسخ
شما برای افزودن پاسخ جدید یا باید وارد شوید یا ثبت نام کنید. ورود ثبت نام.