Created
December 13, 2017 03:23
-
-
Save kurudrive/df51de77063c6f253eb817830915473e to your computer and use it in GitHub Desktop.
WordPressのカスタム投稿タイプで管理画面に表示される公開画面のリンク先を変更する ref: https://qiita.com/kurudrive/items/aa448bbae410bf1d67bc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('post_type_link', 'my_custom_public_link',10,2); | |
function my_custom_public_link($permalink) { | |
// 現在の投稿タイプを取得 | |
$post_type = get_post_type(); | |
// 書き換えたい投稿タイプを指定 | |
if ( $post_type == 'recruit' ){ | |
$permalink = '表示したいページのURL'; | |
} | |
return $permalink; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('post_type_link', 'my_custom_public_link',10,2); | |
function my_custom_public_link($permalink) { | |
// 現在の投稿タイプを取得 | |
$post_type = get_post_type(); | |
// 書き換えたい投稿タイプを指定 | |
if ( $post_type == 'recruit' ){ | |
global $post; | |
// 指定のURLにアンカーリンクも付けて返す | |
$permalink = home_url('/').'★表示したいページまでの階層★/#'.'id-'.$post->ID; | |
} | |
return $permalink; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id="id-<?php echo esc_attr( $post->ID );?>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment