반응형
제목 없이_sublic_interation()을 사용합니다.
_posts_pagination(codex 참조)을 사용하면 페이지 번호에 "post navigation"이라는 제목이 표시됩니다.
이거 꺼도 돼요?
예를 들어 다음과 같은 것을 사용합니다.
the_posts_pagination( array(
'title' => '', // this should hide the title
'prev_text' => __( 'Previous', 'twentyfifteen' ),
'next_text' => __( 'Next', 'twentyfifteen' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( '', 'nieuwedruk' ) . ' </span>',
) );
도움이 되는 "screen_reader_text" 속성이 있습니다.
the_posts_pagination( array(
'screen_reader_text' => ' ',
'prev_text' => __( 'Previous', 'twentyfifteen' ),
'next_text' => __( 'Next', 'twentyfifteen' ),
'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( '', 'nieuwedruk' ) . ' </span>',
) );
주의: 따라서 작은 따옴표 사이에 공백이 있습니다.
솔루션을 찾는 동안 이 링크가 가장 상대적이지만 내 상황에 맞는 완전한 솔루션은 아니라는 것을 알게 되었습니다.위의 답변은 W3C에서 HTML을 검증할 때 경고를 발생시킵니다.
preg_replace()를 사용하여 h2 태그를 삭제하는 액션을 추가하여 제목을 완전히 삭제하는 방법을 찾았습니다.Regex는 제가 제일 잘하는 일이 아니니 제안해주시면 감사하겠습니다.
저는 제 기능에 다음과 같은 조치를 취했습니다.php:
function sanitize_pagination($content) {
// Remove role attribute
$content = str_replace('role="navigation"', '', $content);
// Remove h2 tag
$content = preg_replace('#<h2.*?>(.*?)<\/h2>#si', '', $content);
return $content;
}
add_action('navigation_markup_template', 'sanitize_pagination');
위 기능을 사용하면 탐색 요소에서 "역할" 속성도 제거됩니다(W3C 경고 원인).
오래된 포스트인 것은 알지만 간단한 솔루션을 원하는 사람에게는 간단한 CSS 블록이 도움이 됩니다.php를 변경할 필요가 없습니다.
h2.screen-reader-text {
display: none;
}
또는
.post-navigation h2.screen-reader-text {
display: none;
}
언급URL : https://stackoverflow.com/questions/29863234/use-the-posts-pagination-without-title
반응형
'programing' 카테고리의 다른 글
d3.json을 사용하여 로컬 json 파일을 가져올 수 없음 (0) | 2023.03.15 |
---|---|
비주얼 컴포저에서 동적 필드를 만드는 방법 (0) | 2023.03.15 |
몽고에서 $addToSet 키를 지정할 수 있습니까? (0) | 2023.03.15 |
require("history/createBrowserHistory") 대신 require("history").createBrowserHistory를 응답합니다. (0) | 2023.03.15 |
Oracle SELECT TOP 10 레코드 (0) | 2023.03.15 |