Skip to content

Instantly share code, notes, and snippets.

chocotaro

Block or report user

Report or block chocotaro

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@chocotaro
chocotaro / gazou_quality
Created Apr 8, 2017
WordPressの画像保存クォリティ変更(デフォルトは82)
View gazou_quality
add_filter( 'wp_editor_set_quality', function( $quality ) {
return 100;
} );
@chocotaro
chocotaro / pre_get_post
Created Apr 6, 2017
pre_get_postsでアーカイブページのカテゴリ指定(除去)
View pre_get_post
/* アーカイブページのクエリ操作 */
function myPreGetPosts( $query ) {
if ( is_admin() || ! $query->is_main_query() ){
return;
}
if ( $query->is_archive() ) {
$query->set('cat', -9); //ID=9を除外 マイナスでなければカテゴリ指定
$query->set('posts_per_page', 30);
}
}
@chocotaro
chocotaro / get_posts_news
Created Mar 31, 2017
新着記事表示の例(get_posts)
View get_posts_news
<dl>
<?php $newslist = get_posts('numberposts=0&category=1,2');
//numberposts=0で全ての記事、0以外で記事件数設定。category=カテゴリIDで指定カテゴリのみ表示(カンマ区切り)
foreach( $newslist as $post ):
setup_postdata( $post );
?>
<dt> <?php the_time('Y年n月j日'); ?></dt>
<dd> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a> </dd>
<?php endforeach; wp_reset_postdata(); ?>
</dl>
You can’t perform that action at this time.