Skip to content

Commit

Permalink
アーカイブページで件数0時に正常にポストタイプを取得できない不具合を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Shoji Imamura committed Oct 22, 2014
1 parent d8f0f7c commit 4e3e1fe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 4 additions & 3 deletions index.php
@@ -1,9 +1,10 @@
<?php get_header(); ?>
<?php $postType = get_post_type();
if ( !$postType ) {
// カスタム投稿タイプで該当記事が0件の場合、 get_post_type()で取得できないのでタクソノミーから取得
$taxonomy = get_queried_object()->taxonomy;
$postType = get_taxonomy( $taxonomy )->object_type[0];
global $wp_query;
if ($wp_query->query_vars['post_type']) {
$postType = $wp_query->query_vars['post_type'];
}
} ?>
<!-- [ #container ] -->
<div id="container" class="innerBox">
Expand Down
1 change: 1 addition & 0 deletions module_pageTit.php
Expand Up @@ -17,6 +17,7 @@
/* title
/*-------------------------------------------*/
global $biz_vektor_options;
$pageTitle = '';
if ( is_category() || is_tag() || is_tax() || is_home() || is_author() || is_archive() || is_single() ) {
// ポストタイプを取得
$postType = get_post_type();
Expand Down
4 changes: 4 additions & 0 deletions module_panList.php
Expand Up @@ -203,6 +203,10 @@
$panListHtml .= "<li>".sprintf( __( 'Monthly Archives: %s', 'biz-vektor' ), get_the_date( _x( 'F Y', 'monthly archives date format', 'biz-vektor' ) ) )."</li>";
}
} else {
if(!isset($postTyeName)){
global $wp_query;
$postTypeName = $wp_query->queried_object->labels->name;
}
$panListHtml .= '<li>'.$postTypeName.'</li>';
}

Expand Down
7 changes: 4 additions & 3 deletions sidebar.php
Expand Up @@ -3,9 +3,10 @@
if ( is_active_sidebar( 'common-side-top-widget-area' ) ) dynamic_sidebar( 'common-side-top-widget-area' );
$postType = get_post_type();
if ( !$postType ) {
// カスタム投稿タイプで該当記事が0件の場合、 get_post_type()で取得できないのでタクソノミーから取得
$taxonomy = get_queried_object()->taxonomy;
$postType = get_taxonomy( $taxonomy )->object_type[0];
global $wp_query;
if ($wp_query->query_vars['post_type']) {
$postType = $wp_query->query_vars['post_type'];
}
}
// 投稿タイプのスラッグに紐づいたウィジェットエリアを表示する
$widdget_area_name = $postType.'-widget-area';
Expand Down

0 comments on commit 4e3e1fe

Please sign in to comment.