remove_action( 'wp_head', 'feed_links_extra', 3 ); remove_action( 'wp_head', 'feed_links', 2 ); remove_action( 'wp_head', 'rsd_link' ); remove_action( 'wp_head', 'wlwmanifest_link' ); remove_action( 'wp_head', 'index_rel_link' ); remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'start_post_rel_link', 10, 0 ); remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 ); remove_action( 'wp_head', 'wp_generator' );
<?php echo home_url('',''); ?>
ホームURLがでる
<?php echo home_url('','https'); ?>
こうするとhttps付のURLがでる。
3.0からさりげなく追加されていたみたい。
//httpsも含めたURL吐き出し
function blog_url($string) {
$url = get_bloginfo('url');
if( $string == "https" ){
echo str_replace( "http:", "https:", $url );
}else{
echo str_replace( "https:", "http:", $url );
}
}
こんなの作らなくてもよくなってたのか。
<?php
$cat = get_query_var( 'cat' );
$now_cat = get_the_category();
$args = array(
'orderby'=>'slug',
'get'=>'all'
);
$cat_list = get_terms('category',$args);
//print_r($cat_list);
$cat_num = $now_cat[0]->category_parent;
if( $cat_num == "0" ){
echo "<h3>" .$now_cat[0]->name. "</h3>\n";
echo "<ul>\n";
foreach($cat_list as $cat_title){
if($cat_title->parent == $now_cat[0]->term_id){
if( $cat_title->count != "0"){
echo "<li".$onb."><a href='?cat=".$cat_title->term_id."'>".$cat_title->name."</a></li>\n";
}else{
echo "<li>".$cat_title->name."</li>\n";
}
}
}
}else{
foreach($cat_list as $cat_title){
if($cat_title->term_id == $cat_num) echo "<h3>" .$cat_title->name."</h3>\n";
}
echo "<ul>\n";
foreach($cat_list as $cat_title){
if($cat_title->parent == $cat_num){
if( $now_cat[0]->term_id == $cat ){
$onb = " class='on'";
}
if( $cat_title->count != "0"){
//echo $cat_title->name."\n";
echo "<li".$onb."><a href='?cat=".$cat_title->term_id."'>".$cat_title->name."</a></li>\n";
}else{
echo "<li>".$cat_title->name."</li>\n";
}
}
}
}//endif
echo "</ul>\n";
?>
ごちゃごちゃしてるからこれはまだ整理できるはず。
get_termsは面白いなぁ。
<?php if ( have_posts() ) : $i = 0; while ( have_posts() ) : the_post(); if ( $i % 4 == 0 ) echo '<div class="col clearfix">'; ?> <?php /* ここでループ終了 */ $i++; if ( $i % 4 == 0 ) echo '</div><!-- .col -->'; endwhile; endif; ?>
<?php while ( have_posts() ) : the_post(); ?> <li id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"> <?php $title= get_the_title(); the_post_thumbnail(array( 252,252 ), array( 'alt' =>$title, 'title' => $title)); ?></a> </li> <?php endwhile; ?> <?php wp_reset_query();?>
配列でaltとtitleに取得して来たタイトルを入れる。
なるほどすばらしい。
Template
<div id="sidebar">
<ul>
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
デフォルトの内容を書く
<?php endif; ?>
</ul>
</div>
functions.php
<?php
if ( function_exists('register_sidebar') )
register_sidebar();
?>
ファンクションに記述
/* カスタムヘッダー関係 */
add_custom_image_header('','admin_header_style');
function admin_header_style() {
?>
<style type="text/css">
#headimg {
width: <?php echo HEADER_IMAGE_WIDTH; ?>px;
height: <?php echo HEADER_IMAGE_HEIGHT; ?>px;
}
</style>
<?php
}
define('NO_HEADER_TEXT',true);
define('HEADER_IMAGE','%s/img/main_img.jpg'); //デフォルトの画像指定
define('HEADER_IMAGE_WIDTH',948);
define('HEADER_IMAGE_HEIGHT',145);
以下をテンプレートに張る。
<style>
div#main_img{
background:url(<?php header_image(); ?>);
}
</style>
使い方的には
<img src="<?php header_image(); ?>">
でも行ける。
上の使い方はdiv#main_imgの背景画像に設定した画像を利用する仕様