는 워드 프레스에 고정 링크를 post_type 날짜 태그. 이 코드를 사용하면 /my_type/example-post-slug/
:사용 날짜는 3.0
register_post_type('customtype', array(
...other options...
'rewrite' => array('slug' => 'my_type'),
));
어떻게 날짜를 포함 할 수 있습니까?
는 워드 프레스에 고정 링크를 post_type 날짜 태그. 이 코드를 사용하면 /my_type/example-post-slug/
:사용 날짜는 3.0
register_post_type('customtype', array(
...other options...
'rewrite' => array('slug' => 'my_type'),
));
어떻게 날짜를 포함 할 수 있습니까?
사용이가 일하고 100 % :
'rewrite' => array('slug'=>date('Y').'/'.date('m').'/custom_post_type_slug','with_front'=>true)
당신은 플러그인 Custom Post Type Permalinks으로이 작업을 수행 할 수 있습니다. 플러그인을 설치하고 설정에서 영구 링크 형식을 변경하기 만하면됩니다.
나는 주소 표시 줄에 페이지를로드 할 때 퍼머 링크가 인식되고 보존되지만 편집 화면이나 사이트의 게시물에 대한 다른 링크에서는 업데이트되지 않는 부분 솔루션을 발견했습니다. functions.php 또는 특정 사이트 플러그인에 다음을 추가합니다. example-post-type을 게시물 유형의 식별자로 바꿉니다.
function example_rewrite() {
add_rewrite_rule('^example-post-type/([0-9]{4})/([0-9]{1,2})/([^/]*)/?','index.php?post_type=example-post-type&year=$matches[1]&monthnum=$matches[2]&name=$matches[3]','top');
}
add_action('init', 'example_rewrite');
이 다시 쓰기 API가 here 프로세스가 here를 참조 이해에 대한 자세한 도움말을 찾으려면 문서화 사용합니다.
마음에 두어야 할 한 가지 사실은 두 가지 게시물의 날짜가 다르더라도 두 게시물의 슬러그가 같지 않음을 의미합니다. 이것은 퍼머 링크 스키마가 변경되면 충돌하여 오류가 발생할 수 있기 때문입니다.