2016-05-24 8 views
0

私はWordPressでページのクラスのリンクを取得しようとします。WordPress:カテゴリのリンクを参照

http://localhost:8888/Scriptura/ScripturaForWordpress/category/a-category/ 

私は成功せず、これを試してみました:

get_category_link(is_category()); 

続行する方法は?

答えて

0

は最後に、私は解決策を見つけましたが、WordPressはこの1で私を気に、私は回避策を採用した:

$uri = '//' .$_SERVER[ 'HTTP_HOST' ] . $_SERVER[ 'REQUEST_URI' ]; // Alternative to get_permalink() does not work in all situations. In real life this variable is global. 

$arrayHttp = [ 'http://', 'https://' ]; // Here it's not very nice, is to prepare the str_replace that follows ... 
$testLink = ($tabUri == $uri); 
foreach ((array) $menu_items as $key => $menu_item) { 
      $title = $menu_item->title; 
      $tabUri = $menu_item->url; // It retrieves the URL of the tab 
      $tabUri = str_replace($arrayHttp, '//', $tabUri); // Treatment allows for comparison with the variable $url. If you have a solution for dealing with HyperText Transfer Protocol in a more elegant way, I'm interested ... 
      // Following the foreach... 
} 
0

get_category_link()は、パラメータとしてcategory_idを必要とします。次のような言うことができる:

get_category_link(get_cat_ID($cat_name));

関連する問題