2017-04-21 1 views
0

다음 WordPress 사용자 정의를 도와 ​​줄 수 있는지 궁금합니다. 우리는 WP 작업 관리자 플러그인 (https://wpjobmanager.com/)을 사용하고 있으며 슬러그/퍼멀 링크 편집에 약간의 도움이 필요합니다.WP 작업 관리자 용 스 니펫과 함께 도움이 필요합니다.

문서에 사용 가능한 문서는 다음과 같습니다. 현재 상황에서 링크는 다음과 같이 생성됩니다. domain.com/job/job-name. 그러나 domain.com/job-category/job-name 구조가 필요합니다.

확인하시기 바랍니다 : https://wpjobmanager.com/document/tutorial-changing-the-job-slugpermalink/

글이 설명합니다. 다음 코드를 확인하십시오. 예 : 기본 URL에 범주 추가. 다음 코드에서 '작업'을 제거하면 작업 목록이 정상적으로 작동하지만 웹 사이트의 나머지 부분은 (퍼머 링크를 저장 한 후에도) 404 오류로 반환됩니다.

$args['rewrite']['slug'] = 'job/%category%'; 

으로
$args['rewrite']['slug'] = '%category%'; 

전체 코드 :

function job_listing_post_type_link($permalink, $post) { 
    // Abort if post is not a job 
    if ($post->post_type !== 'job_listing') 
     return $permalink; 

    // Abort early if the placeholder rewrite tag isn't in the generated URL 
    if (false === strpos($permalink, '%')) 
     return $permalink; 

    // Get the custom taxonomy terms in use by this post 
    $terms = wp_get_post_terms($post->ID, 'job_listing_category', array('orderby' => 'parent', 'order' => 'ASC')); 

    if (empty($terms)) { 
     // If no terms are assigned to this post, use a string instead (can't leave the placeholder there) 
     $job_listing_category = _x('uncat', 'slug'); 
    } else { 
     // Replace the placeholder rewrite tag with the first term's slug 
     $first_term = array_shift($terms); 
     $job_listing_category = $first_term->slug; 
    } 

    $find = array(
     '%category%' 
    ); 

    $replace = array(
     $job_listing_category 
    ); 

    $replace = array_map('sanitize_title', $replace); 

    $permalink = str_replace($find, $replace, $permalink); 

    return $permalink; 
} 
add_filter('post_type_link', 'job_listing_post_type_link', 10, 2); 

function change_job_listing_slug($args) { 
    $args['rewrite']['slug'] = 'job/%category%'; 
    return $args; 
} 
add_filter('register_post_type_job_listing', 'change_job_listing_slug'); 
+1

자원 봉사자

http://www.wpbeginner.com/plugins/how-to-change-custom-post-type-permalinks-in-wordpress/

그들의 도움을 청구하지 않습니다, 그래서 지불 아웃 당신의 제안을 편집했습니다. 질문에 충분한 세부 사항이 있고 너무 광범위한 질문이 아니라면 여기서 도움을 얻어야합니다. – halfer

+0

고마워, 나는 그 사실을 몰랐다! – Festinger

답변

-1

잘가, 나 또한 한 번 오류의 몇 가지 유형에 갇혀 있었다. 하지만 제 경우에는 모든 것을 내 자신으로 만들어야했습니다. 그래서 나는 그에 따라 템플릿을 바꾼다.

그러나이 경우 URL 재 작성과 관련이 있다고 생각합니다. 다음 링크를 확인하십시오. 도움이되기를 바랍니다.

여기 스택 오버플로 https://codex.wordpress.org/Rewrite_API/add_rewrite_rule https://paulund.co.uk/rewrite-urls-wordpress

+0

제안 해 주셔서 감사합니다. 그러나 '작업'슬러그를 편집 할 수 없습니다. 이 스크린 샷을 확인하십시오 : http://imgur.com/4uU7cj3 – Festinger

관련 문제