2016-02-29 129 views
0

我搜索了爲什麼我的get_header()函數在我的插件中不起作用。所有可能的解決方案都表示index.php文件可能已損壞。但在我的情況下,它工作正常。我的錯誤與在stackexchange上解決的有關get_header()的其他錯誤不同。get_header()函數不能在wordpress插件文件夾中工作

請同時幫助我如何從插件文件夾中顯示我的searchresult.php。如果我在其中添加任何wordpress功能,它說undefined function。像get_header(),插件文件夾等

我的代碼:

​​3210

searchform.php

<style> 
.search{ 
    border:0px solid #E5E5E5; 
width: 100%; 
height:90px; 
padding:0px;  


} 
.search ul li{ 
    list-style:none; 
    padding:0px; 
    display:inline-block !important; 
    position:relative; 
    float:none !important; 
    text-align:left; 

} 
.widget input.search-field[type="search"] { 
width:100%; 
} 

</style> 


<div class="search"><?php 

/** 
* Template for displaying search forms in Twenty Sixteen 
* 
* @package WordPress 
* @subpackage Twenty_Sixteen 
* @since Twenty Sixteen 1.0 
*/ 
$url = plugins_url(); 
get_header(); 
?> 

<form role="search" method="get" class="search-form" action="<?php echo $url; ?>/magicsearch/searchm.php" > 
    <label> 
     <span class="screen-reader-text"><?php echo _x('Search for:', 'label', 'twentysixteen'); ?></span> 
     <input type="search" class="search-field" placeholder="<?php echo esc_attr_x('Search &hellip;', 'placeholder', 'twentysixteen'); ?>" value="<?php echo get_search_query(); ?>" name="s" title="<?php echo esc_attr_x('Search for:', 'label', 'twentysixteen'); ?>" /> 
    </label> 
    <button type="submit" class="search-submit"><span class="screen-reader-text"><?php echo _x('Search', 'submit button', 'twentysixteen'); ?></span></button> 
</form> 
</div> 

**我的插件儀表盤文件** plugin_index.php

<?php 
/* 
Plugin Name: Magic Search 
Plugin URI: # 
Description: Magic Search use for to find article from archive otherwise query saved. 
Author: Manmohan 
Author URI: # 
*/ 
// PLUGIN ACTIVATION BY CODE 
//function myplugin_activate() { 
    // Activation code here... 
//} 
//register_activation_hook(__FILE__, 'myplugin_activate'); 
function createTable(){ 

    global $wpdb; 
    $query = "CREATE TABLE IF NOT EXISTS " . $wpdb->prefix ."newkeyword (
     query_id INT NOT NULL AUTO_INCREMENT, 
     keyword VARCHAR(25) NOT NULL, 
     PRIMARY KEY (query_id) 
     ) ENGINE=MyISAM DEFAULT CHARSET=utf8"; 
    $wpdb->query($query); 
} 

register_activation_hook(__FILE__, 'createTable'); 

//ADD SHORTCODE 
register_activation_hook(__FILE__, 'searchbar_function'); 
add_shortcode('searchbar', 'searchbar_function'); 

function searchbar_function(){ 

    include('searchf.php'); 
    include('searchm.php'); 

} 
// Hook for adding admin menus 
add_action('admin_menu', 'disp_queries'); 
// action function for above hook 
function disp_queries(){ 
    /*    Browser Top Title use at                    */ 
    /*    Title Text WP Admin LFT Bar                    */ 
    /*     \/    \/                   */ 

    add_menu_page('Magic Search', 'Magic Search', 'manage_options', 'searchpage', 'my_custom_menu_page', plugins_url('magicsearch/se.png'), 6); 
} 

function my_custom_menu_page(){ 
    include('adminresult.php'); 


//tguy_sm_summary_table(30); 
    } 







?> 
+0

這就是我的插件的所有代碼。 –

回答

0

你有沒有在主題背景中設置頁眉和頁腳.php文件R'可能看起來像一個愚蠢的問題,但它已知發生。

有關搜索的問題,我不是100%確定那一個,但這個get_search_form topic可以幫助

這是一個自定義的主題或一個你已經選擇爲默認?

+0

它的默認WordPress主題。頁眉和頁腳設置在.php文件中。除了如果我添加我的插件文件夾的get_header()和footer()函數searchresult.php文件,每件事情都很好。 –