[WordPress]詳細ページ不要
functions.php
add_filter('カスタム投稿タイプ_rewrite_rules','__return_empty_array');
ACF Proの場合
下図赤枠をOFF
functions.php
add_filter('カスタム投稿タイプ_rewrite_rules','__return_empty_array');
ACF Proの場合
下図赤枠をOFF
functions.php
/** * WP_Termの配列の各要素にterm_ordersを設定する * * @param array $terms * */ function set_parents_term_orders_to_terms(&$terms) { if(empty($terms)){ return; } foreach ($terms as $i => $term) { $terms[$i]->term_orders = [$term->term_order]; if(!empty($term->parent)){ $tmp = $term; while(!empty($tmp->parent)){ $tmp_id = $tmp->term_id; foreach ($terms as $j => $term_) { if($tmp->parent === $term_->term_id){ array_unshift($terms[$i]->term_orders,$term_->term_order); $tmp = $term_; break; } } if($tmp_id === $tmp->term_id){ break; } } } } } /** * WP_Termの配列をterm_ordersに則ってソートする * set_parents_term_orders_to_terms を実行してから使用する * * @param array $terms * */ function sort_terms_by_term_orders(&$terms) { usort($terms,function($a,$b){ $imax = max(count($a->term_orders),count($b->term_orders)); for($i=0;$i<$imax;$i++){ if(count($a->term_orders) <= $i){ return -1; } if(count($b->term_orders) <= $i){ return 1; } if($a->term_orders[$i] === $b->term_orders[$i]){ continue; } return ($a->term_orders[$i] > $b->term_orders[$i]) ? 1 : -1; } }); } /** * 管理画面記事一覧カテゴリフィルタ追加 */ function add_post_taxonomy_restrict_filter() { global $post_type; if($post_type === 'カスタム投稿タイプ'){ ?> <select name="タクソノミー"> <option value="">カテゴリーを指定する</option> <?php $terms = get_terms('タクソノミー'); /* プラグイン「Category Order and Taxonomy Terms Order」導入済みの場合 set_parents_term_orders_to_terms($terms); sort_terms_by_term_orders($terms); */ foreach ($terms as $term) { ?> <option value="<?php echo $term->slug; ?>"><?php echo $term->name; ?></option> <?php } ?> </select> <?php } } add_action('restrict_manage_posts', 'add_post_taxonomy_restrict_filter');
/** * WordPress標準の不要ページを無効化 * @param WP_Query $query */ function force_404($query) { if(is_attachment() || is_author() || is_search() || is_date() || is_tag()){ /** 404ページを返す */ $query->set_404(); /** 404コードを返す */ status_header(404); /** キャッシュの無効化 */ nocache_headers(); } } add_filter('parse_query', 'force_404');
/** いきもの図鑑詳細ページを無効化 */ add_filter('カスタム投稿タイプ_rewrite_rules', '__return_empty_array');
/** meta name="generator" を非表示にする */ remove_action('wp_head', 'wp_generator'); /** EditURIを非表示にする */ remove_action('wp_head', 'rsd_link'); /** wlwmanifestを非表示にする */ remove_action('wp_head', 'wlwmanifest_link'); /** 短縮URLを非表示にする */ remove_action('wp_head', 'wp_shortlink_wp_head'); /** 絵文字用JS・CSSを非表示にする */ remove_action('wp_head', 'print_emoji_detection_script', 7); remove_action('admin_print_scripts', 'print_emoji_detection_script'); remove_action('wp_print_styles', 'print_emoji_styles'); remove_action('admin_print_styles', 'print_emoji_styles'); /** 投稿の RSS フィードリンクを非表示にする */ remove_action('wp_head', 'feed_links', 2); /** コメントフィードを非表示にする */ remove_action('wp_head', 'feed_links_extra', 3); /** dns-prefetchを非表示にする */ add_filter('wp_resource_hints', 'remove_dns_prefetch', 10, 2); /** * @param array $hints * @param string $relation_type * * @return array */ function remove_dns_prefetch($hints, $relation_type) { if($relation_type === 'dns-prefetch'){ return array_diff(wp_dependencies_unique_hosts(), $hints); } return $hints; } /** wp versionを非表示にする */ remove_action('wp_head','rest_output_link_wp_head'); /** oEmbedを非表示にする */ remove_action('wp_head','wp_oembed_add_discovery_links'); /** rel="next" rel="prev" を非表示にする */ remove_action('wp_head','adjacent_posts_rel_link_wp_head'); /** <meta name='robots' content='max-image-preview:large' />を非表示にする */ remove_filter('wp_robots','wp_robots_max_image_preview_large');
function get_parents($post,$parents = array()) { if (!empty($post->post_parent)){ $parent = get_post($post->post_parent); array_unshift( $parents, $parent); return get_parents( $parent, $parents ); } return $parents; } function the_parents($post,$format) { $parents = get_parents($post); if(!empty($parents)){ foreach($parents as $i => $parent){ $html = $format; $html = preg_replace('/%permalink%/',get_permalink($parent->ID),$html); $html = preg_replace('/%title%/',esc_html($parent->post_title),$html); echo $html; } } }
function disable_jsonld_of_aioseo() { return true; } add_filter('aioseo_schema_disable', 'disable_jsonld_of_aioseo');
function custom_image_size() { add_image_size('news_pc',270,466,true); add_image_size('news_sp',335,168,true); add_image_size('newsdetail',340,170,true); } add_action('after_setup_theme', 'custom_image_size');
function add_admin_style() { wp_enqueue_script('admin_script', get_template_directory_uri().'/scripts/admin.js'); wp_enqueue_style('admin_style', get_template_directory_uri().'/style/admin.css'); } add_action('admin_enqueue_scripts', 'add_admin_style');
function custom_remove_menus() { global $menu; /** 投稿 */ remove_menu_page('edit.php'); /** コメント */ remove_menu_page('edit-comments.php'); } add_action('admin_menu', 'custom_remove_menus');