2012-11-11 2 views
0

안녕하세요, 부모님 께 수업을 추가하는 방법을 궁금합니다. <a> 태그.학부모에게 클래스를 추가 <a> 태그. Wordpress

<a href="http://localhost/?page_id=354">Link</a> 

그러나 나는 다음과 같이 표시 할 :

나는) (wp_list_pages를 사용하여이 얻을

<a href="http://localhost/?page_id=354" class="navA">Link</a> 

그리고 나는 아이들에 <a> 태그뿐만 아니라 부모님에이 원하는 . 감사합니다. 당신이 사업부에서 이러한 모든 링크를 포장하는 경우, 예를 들어

+0

http://wordpress.stackexchange.com/questions/11821/class-parent-for-wp-list-pages –

답변

-1

다음과 같이

<div id="pages-wrapper"><?php wp_list_pages(); ?></div> 

그런 다음 jQuery를 addClass()를 사용할 수 있습니다 또한

$('div#pages-wrapper a').addClass('navA'); 

, 워드 프레스 관련위한 영역이있다 StackExchange에 대한 질문 : http://wordpress.stackexchange.com

+0

-1s에 대한 의견을 남겨주세요. – apparatix

0

wp_list_pages를 확장하려면 사용자 정의 워커를 만들 수 있습니다. 당신이 전화를 원하는 functions.php

class My_Custom_Walker extends Walker_Nav_Menu { 
    function start_el (&$output, $item, $depth=0, $args=array()) { 

    $link = get_permalink($item->ID); 
    $title = $item->post_title; 
    $indent = str_repeat("\t", $depth); 
    $output .= "\n$indent<li>\n<a href='".$link."' class='navA'>".$title."</a>"; 

    } 

    function end_el(&$output, $item, $depth=0, $args=array()) { 
     $indent = str_repeat("\t", $depth); 
     $output .= "\n$indent</li>\n"; 
    } 
} 

초기화 및 보행자 및 사용에

사용자 정의 워커.

<?php 
// Call class: 
$My_Walker = new My_Custom_Walker(); 

$args = array(
    'walker'  => $My_Walker 
); 

wp_list_pages($args); 

?> 

참조 링크 :

http://codex.wordpress.org/Function_Reference/wp_list_pages

또한 당신은 그것을 달성하기 위해 후크를 사용할 수 있습니다.

https://wordpress.stackexchange.com/questions/42701/how-to-hook-wp-list-pages