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
<?php | |
//困った時の | |
print_r($wp_query); | |
//で、 | |
$hoge = get_queried_object(); | |
print_r($hoge); | |
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
<?php | |
//IDの取得 | |
echo get_term_by('slug',$term,$taxonomy)->term_id; | |
//名前の取得 | |
echo get_term_by('slug',$term,$taxonomy)->name; | |
//URLの取得 | |
echo get_term_link($term,$taxonomy); | |
/* |
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
//function.phpに追記 | |
add_filter('template_include','custom_search_template'); | |
function custom_search_template($template){ | |
if ( is_search() ) { | |
//表示する投稿タイプを取得→それをsearch-★.phpの★部分に埋め込む | |
$post_types = get_query_var('post_type'); | |
foreach ( (array) $post_types as $post_type ) | |
$templates[] = "search-{$post_type}.php"; | |
$templates[] = 'search.php'; | |
$template = get_query_template('search',$templates); |
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
<?php the_time(); ?> | |
現在の記事の投稿時間を表示。 | |
<?php the_date(); ?> | |
現在の記事の投稿日時を表示。 | |
<?php the_title(); ?> | |
現在の記事のタイトルを表示 | |
<?php the_content(); ?> |
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
<?php if(get_field('movie_flag') == 'search'): ?> | |
<?php | |
$search = get_field('movie_tag'); | |
$max_result = get_field('movie_count'); | |
$arg = | |
array( | |
'post_type' => 'd_movie', | |
'posts_per_page' => $max_result , | |
'tax_query' => array( | |
array( |
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
<?php | |
//hoge:出力したいカスタムタクソノミー | |
$tarms = get_the_terms( $post -> ID ,'hoge' ); | |
foreach ( $tarms as $tarm ) {echo $tarm -> name;} | |
//'category''post_tag'でそれぞれdefaultカテゴリーとタグも利用可 | |
//$termsの[数値]はどーもカテゴリID諸々が入る様で[0]とかでは空っぽ。 | |
?> |
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
stdClass Object | |
( | |
[ID] => 4025 | |
[post_author] => 2 | |
[post_date] => 2010-04-24 18:07:14 | |
[post_date_gmt] => 2010-04-24 09:07:14 | |
[post_content] => WordPress ではページ毎にテンプレートを用意することが可能... | |
[post_title] => WordPress のページテンプレートの情報を取得する方法 | |
[post_category] => 0 | |
[post_excerpt] => |
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
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> | |
//ACFの基礎形 | |
<?php the_field('hoge'); ?> | |
<?php endwhile;?> | |
<?php endif; ?> |
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
<?php | |
global $template; | |
$now_template = $template; | |
//hoge:Themeを入れているフォルダの名称 | |
$now_template = preg_replace("/.+hoge\/(.+).php/","\\1",$now_file); | |
?> |