get_term_link [ WordPress Function ]
get_term_link ( $term, $taxonomy = '' )
| Parameters: |
|
| Uses: | |
| Returns: |
|
| Defined at: |
|
Benzer Fonksiyonlar: edit_term_link, get_permalink, get_year_link, get_term_feed_link, get_edit_term_link
Generates a permalink for a taxonomy term archive.
Source
<?php
function get_term_link( $term, $taxonomy = '') {
global $wp_rewrite;
if ( !is_object($term) ) {
if ( is_int($term) ) {
$term = &get_term($term, $taxonomy);
} else {
$term = &get_term_by('slug', $term, $taxonomy);
}
}
if ( !is_object($term) )
$term = new WP_Error('invalid_term', __('Empty Term'));
if ( is_wp_error( $term ) )
return $term;
$taxonomy = $term->taxonomy;
$termlink = $wp_rewrite->get_extra_permastruct($taxonomy);
$slug = $term->slug;
$t = get_taxonomy($taxonomy);
if ( empty($termlink) ) {
if ( 'category' == $taxonomy )
$termlink = '?cat=' . $term->term_id;
elseif ( $t->query_var )
$termlink = "?$t->query_var=$slug";
else
$termlink = "?taxonomy=$taxonomy&term=$slug";
$termlink = home_url($termlink);
} else {
if ( $t->rewrite['hierarchical'] ) {
$hierarchical_slugs = array();
$ancestors = get_ancestors($term->term_id, $taxonomy);
foreach ( (array)$ancestors as $ancestor ) {
$ancestor_term = get_term($ancestor, $taxonomy);
$hierarchical_slugs[] = $ancestor_term->slug;
}
$hierarchical_slugs = array_reverse($hierarchical_slugs);
$hierarchical_slugs[] = $slug;
$termlink = str_replace("%$taxonomy%", implode('/', $hierarchical_slugs), $termlink);
} else {
$termlink = str_replace("%$taxonomy%", $slug, $termlink);
}
$termlink = home_url( user_trailingslashit($termlink, 'category') );
}
// Back Compat filters.
if ( 'post_tag' == $taxonomy )
$termlink = apply_filters( 'tag_link', $termlink, $term->term_id );
elseif ( 'category' == $taxonomy )
$termlink = apply_filters( 'category_link', $termlink, $term->term_id );
return apply_filters('term_link', $termlink, $term, $taxonomy);
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/get term link « WordPress Codex
Description. Returns permalink for a taxonomy term archive. Usage. <?php get_term_link( $term, $taxonomy ); ?> Parameters. $term: (object/int/string) ( required) ...
codex.wordpress.org - WordPress › Support » Tags — get_term_link
Register · WordPress › Support » get_term_link. Tag: get_term_link Add New » ... [resolved] get_the_term_list() or get_term_link() issue? 1, Eos Rose, 11 months ...
wordpress.org - Can anyone help me with Wordpress's get_term_link()? | ThemeForest ...
I found the get_term_link() function in /wp-includes/taxonomy.php and I've been trying to use it, as it seems pretty straight forward, but I just can't ...
themeforest.net - get_term_link() | Rachel Carden
This WordPress function requires the CPT-onomy class. Description; Usage; Parameters; Return Values; Examples; Related Functions; WordPress Codex ...
rachelcarden.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- kilobytes on "Custom taxonomies create bad links"
- kilobytes on "Custom taxonomies create bad links"
- Ipstenu on "WP warnings for custom taxonomies"
- kilobytes on "WP warnings for custom taxonomies"
- kilobytes on "WP warnings for custom taxonomies"
- Andrew Nacin on "WP warnings for custom taxonomies"
- kilobytes on "WP warnings for custom taxonomies"
- Eos Rose on "get_the_term_list() or get_term_link() issue?"
- laughhearty on "Need to Place link in template that targets specific taxonomy term"
- jkovis on "Need to Place link in template that targets specific taxonomy term"