2016-07-18 2 views
1

커스텀 Wordpress 테마를 개발 중이며, 내 테마에서 선택된 메뉴 링크에 문제가 있습니다!Wordpress 커스텀 테마에서 선택된 메뉴 링크가 작동하지 않습니다.

기본적으로 selected이라고하는 CSS 파일에 클래스 이름을 추가했습니다. 상단 메뉴 탐색에 현재 페이지를 표시하는 방법을 보여줍니다.

는 CSS 파일입니다

.ddsmoothmenu{ 
    float: right; 
    margin-top: 10px 
} 

.ddsmoothmenu ul{ 
    z-index:100; 
    margin: 0; 
    padding: 0; 
    list-style-type: none; 
} 

/*Top level list items*/ 
.ddsmoothmenu ul li{ 
    position: relative; 
    display: inline; 
    float: left; 
} 

/*Top level menu link items style*/ 
.ddsmoothmenu ul li a{ 
    display: block; 
    height: 26px; 
    line-height: 23px; 
    padding: 0 20px 5px 15px; 
    margin: 0 7px 0 0; 
    font-size: 14px; 
    color: #333;  
    text-align: center; 
    text-decoration: none; 
    font-weight: 700; 
    outline: none; 
    border: none; 
} 

* html .ddsmoothmenu ul li a{ /*IE6 hack to get sub menu links to behave correctly*/ 
display: inline-block; 
} 

.ddsmoothmenu ul li a.selected, .ddsmoothmenu ul li a:hover { /*CSS class that's dynamically added to the currently active menu items' LI A element*/ 
    position: relative; 
    background: url(../images/templatemo_mhr.png) no-repeat top right; 
} 

.ddsmoothmenu ul li a.selected span, .ddsmoothmenu ul li a:hover span { 
    position: absolute; 
    width: 5px; 
    height: 26px; 
    top: 0; 
    left: -5px; 
    background: url(../images/templatemo_mhl.png) no-repeat; 
} 

/*1st sub level menu*/ 
.ddsmoothmenu ul li ul{ 
    position: absolute; 
    left: 0; 
    display: none; /*collapse all sub menus to begin with*/ 
    visibility: hidden; 
    background: #bad8f7; 
} 

/*Sub level menu list items (undo style from Top level List Items)*/ 
.ddsmoothmenu ul li ul li{ 
display: list-item; 
float: none; 
} 

/*All subsequent sub menu levels vertical offset after 1st level sub menu */ 
.ddsmoothmenu ul li ul li ul{ 
top: 0; 
} 

/* Sub level menu links style */ 
.ddsmoothmenu ul li ul li a{ 
    font-weight: 500; 
    width: 120px; /*width of sub menus*/ 
    padding: 2px 10px; 
    margin: 0; 
    font-size: 12px; 
    border-top-width: 0; 
    text-align: left; 
} 


.ddsmoothmenu ul li ul li a.selected, .ddsmoothmenu ul li ul li a:hover { text-decoration: underline; background: none } 

/* Holly Hack for IE \*/ 
* html .ddsmoothmenu{height: 1%;} /*Holly Hack for IE7 and below*/ 


/* ######### CSS classes applied to down and right arrow images ######### */ 

.downarrowclass{ 
position: absolute; 
top: 12px; 
right: 7px; 
} 

.rightarrowclass{ 
position: absolute; 
top: 6px; 
right: 5px; 
} 

/* ######### CSS for shadow added to sub menus ######### */ 

.ddshadow{ 
position: absolute; 
left: 0; 
top: 0; 
width: 0; 
height: 0; 
background: #fff; 
} 

.toplevelshadow{ /*shadow opacity. Doesn't work in IE*/ 
opacity: 0.5; 
} 

/* menu */ 

그리고 여기 header.php 파일 메뉴의 레이아웃입니다 : 사용자가 클릭 그래서 만약 현재 메뉴 페이지로 클래스 selected을 추가하는 방법

<div id="templatemo_header"> 
     <div id="site_title"><h1><a href="#">Violet Theme</a></h1></div> 
     <div id="templatemo_menu" class="ddsmoothmenu"> 
      <?php 
      $args = array(
       'theme_location' => 'primary' 
      ); 
      wp_nav_menu($args); 
      ?> 
      <br style="clear: left" /> 
     </div> <!-- end of templatemo_menu --> 

     <div class="cleaner"></div> 
    </div> <!-- end of templatemo header --> 

블로그 페이지 예를 들어, 블로그 항목이 메뉴에서 선택한 항목의 스타일로 변경되었습니다.

답변

1

당신은 current-menu-item을 사용할 수를 현재보고 있습니다. current_page_item은 메뉴 항목이 페이지 인 경우에만 추가되므로 사용하지 않는 것이 좋습니다.

0

당신이 메뉴를 선택할 때 wordpress에서 당신은 종류 current_page_item가있을 것이다. 당신은

.current_page_item a{color: #xxxxxx;} 

여기에 <a>의 색상을 설정할 수 있습니다 그리고 당신은 색상을 설정하려면 TI 페이지/글/카테고리에 추가되기 때문에 때 가져가

.category a:hover{color: #xxxxxx;} 
관련 문제