2013-03-15 40 views
0

自定義WordPress的生成路徑鏈接

我使用WordPress的,和我使用的是麪包屑插件(麪包屑NavXT)。現在,它的偉大工程,exept我想自定義鏈接到一個特定聯繫方式:

現在這裏是情景:

我有一個頁面,頁面上有鏈接發佈。因此,當您點擊頁面上的某個鏈接時,它會將您帶到帖子中。現在這個帖子屬於一個名爲Drill Rigs的類別,而Drill Rigs是一個產品的子類別。

現在的帖子頁面,其中有類別的產品>鑽機「(父/子)上,麪包屑顯示方式如下:

Home>products>drill rigs>postname 

問題是,你點擊產品鏈接上面的,它需要你的產品類別頁:

siteurl/category/products 

,而不是實際的WordPress頁面被稱爲產品(包含鏈接到上述職位的鏈接:

siteurl /絕對鏈接到頁面,這是一個獨特的鏈接,例如。 siteurl/803-2

現在據我所知,你不能改變從一個類別(這是帖子唯一的)到頁面的路徑,無論是在wordpress或插件。

我能想到的最好的方法是添加自定義jQuery或PHP的PHP頁面(或索引/頁眉頁),尋找容器div包含主持標題'產品'錨定標籤...然後用我的自定義唯一頁面網址替換該錨標記...

我該怎麼做...?

回答

0

您可以使用該功能通過編碼來設置麪包屑:

function the_breadcrumb() { 
if (!is_home()) { 
    echo '<a href="'; 
    echo get_option('home'); 
    echo '">'; 
    echo "Home";//bloginfo('name'); 
    echo "</a>/"; 
    if (is_category() || is_single()) { 
     the_category('title_li='); 
     if (is_single()) { 
      echo "/"; 
      the_title(); 
     } 
    } elseif (is_page()) { 
     echo the_title(); 
    } 
} 

}

把上面的代碼中function.php文件

你只是調用函數,你想顯示bredcrumb

<?php the_breadcrumb(); ?> 

希望這會幫助你...

+0

感謝你的努力Vickey,但不幸的是它不工作......每次只顯示首頁>鑽機。它不包括麪包屑 – DextrousDave 2013-03-15 09:19:21

+0

中的'產品'鏈接,該插件用於顯示產品,如果它的wp-ecommerce然後在後端設置,以顯示產品頁面上的產品或類別更改設置 – 2013-03-15 09:57:09

+0

不,它是Breadcrumb NavXT ... – DextrousDave 2013-03-15 10:19:42

1
function the_breadcrumb() { 

$sep = '/'; 

if (!is_front_page()) { 

    echo '<div class="breadcrumbs">'; 
    echo '<a href="'; 
    echo get_option('home'); 
    echo '">'; 
    bloginfo('name'); 
    echo '</a>' . $sep; 

    if (is_category() || is_single()){ 
     the_category('title_li='); 
    } elseif (is_archive() || is_single()){ 
     if (is_day()) { 
      printf(__('%s', 'text_domain'), get_the_date()); 
     } elseif (is_month()) { 
      printf(__('%s', 'text_domain'), get_the_date(_x('F Y', 'monthly archives date format', 'text_domain'))); 
     } elseif (is_year()) { 
      printf(__('%s', 'text_domain'), get_the_date(_x('Y', 'yearly archives date format', 'text_domain'))); 
     } else { 
      _e('Blog Archives', 'text_domain'); 
     } 
    } 

    if (is_single()) { 
     echo $sep; 
     the_title(); 
    } 

    if (is_page()) { 
     echo the_title(); 
    } 

    if (is_home()){ 
     global $post; 
     $page_for_posts_id = get_option('page_for_posts'); 
     if ($page_for_posts_id) { 
      $post = get_page($page_for_posts_id); 
      setup_postdata($post); 
      the_title(); 
      rewind_posts(); 
     } 
    } 

    echo '</div>'; 
} 

}

試試這個,希望這可以幫助你

0
<script type="text/javascript"> 
$('#breadcrumbs .category[href="http://mysite.com/category/products"]').attr('href','http://mysite.com/803-2'); 
</script> 

其中:

http://mysite.com/803-2 

是p [年齡我想鏈接到的網址...

相關問題