Foros del Web » Creando para Internet » Sistemas de gestión de contenidos » WordPress »

modificar get_term_link

Estas en el tema de modificar get_term_link en el foro de WordPress en Foros del Web. hola hice una modificacion en el nucleo de wordpress, concretamente el archivo taxonomiy.php para que las categorias no muestre las categorias dependientes en su link ...
  #1 (permalink)  
Antiguo 12/04/2011, 15:15
p2pdownloading
Invitado
 
Mensajes: n/a
Puntos:
modificar get_term_link

hola hice una modificacion en el nucleo de wordpress, concretamente el archivo taxonomiy.php para que las categorias no muestre las categorias dependientes en su link

lo que hice fue eliminar la variblae $ancestors = get_ancestors($term->term_id,

quería saber como hacer esto desde un plugin para no tener que hacerlo cada vez que actualizo wordpress

saludos

Código 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();
            [
B]//$ancestors = get_ancestors($term->term_id, [/B]$taxonomy);132613
            
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_urluser_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);

  #2 (permalink)  
Antiguo 13/04/2011, 17:10
Avatar de j_aroche
Server Ninja
 
Fecha de Ingreso: agosto-2006
Ubicación: iPhone: 14.624481,-90.487457
Mensajes: 2.066
Antigüedad: 17 años, 8 meses
Puntos: 223
Respuesta: modificar get_term_link

Lo que haces es usar un hook:

Código PHP:
Ver original
  1. add_filter('term_link' , 'remove_ancestors', 3 );

Este se llamaría al final de la función que colocaste, en base a los parámetros que te manda el filtro puedes "reconstruir" el enlace.
__________________
Blog: JavierAroche.com - Twitter: @j_aroche

Etiquetas: modificar
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 14:55.