php
  • wordpress
  • 2012-07-30 31 views 0 likes 
    0

    我目前有一個插件,顯示我的網站的博客作者的圖像。WordPress的替代使用GET?

    插件如下:

    function display_authors() { 
        global $wpdb; 
        $authors = $wpdb->get_results("SELECT * from $wpdb->users ORDER BY display_name"); 
    
    
        $output = '<ul id="authors">'; 
    
        foreach($authors as $author) { 
    
         if($author->display_name != 'admin') 
         { 
          // display user image for each author 
          $output .= '<li class="author" id="author-'.$author->ID.'">'; 
          // userphoto function echoes image HTML rather than returning it 
          $output .= userphoto($author->ID); 
          $output .= '</li>'; 
         } 
        } 
    
        $output .= '</ul>'; 
    
        echo $output; 
    } 
    
    add_shortcode('oe-list-authors', 'display_authors'); 
    

    我想知道是如何鏈接到一個網頁,我將展示一些作者的元含量及其最新的帖子等

    的我希望這是相同的頁面,因爲它需要在導航欄中具有相同的父項。

    通常在PHP中,您可以檢查是否存在GET變量集,以便您可以顯示作者列表和頁面內容以及特定作者的配置文件信息,但我不知道如何在Wordpress的範圍內做到這一點,我真的很感謝一些幫助。

    回答

    1

    我可能是錯的,但我覺得你還是可以訪問使用$_GET['varname']

    看到這個頁面GET變量:

    http://wordpress.org/support/topic/using-custom-_get-variables-with-templates-and-permalinks

    所以你嘗試過:

    $whatever = $_GET['somevar']; 
    

    +0

    注意:不要使用'p'作爲變量名! – Kasapo 2012-07-30 15:51:06

    +0

    感謝,由於某種原因,我認爲會有一種'wordpress的方式'做到這一點,但這似乎工作時,我認爲它不會! – martincarlin87 2012-08-01 08:30:56

    相關問題