Skip to content

Instantly share code, notes, and snippets.

<?php
// [gist id="ID" file="FILE"]
function gist_shortcode($atts) {
return sprintf(
'<script src="https://gist.github.com/%s.js%s"></script>',
$atts['id'],
$atts['file'] ? '?file=' . $atts['file'] : ''
);
} add_shortcode('gist','gist_shortcode');
add_action( 'register_form', 'add_register_field' );
function add_register_field() { ?>
<p>
<label><?php _e('ここに質問内容') ?><br />
<input type="text" name="user_proof" id="user_proof" class="input" size="25" tabindex="20" /></label>
</p>
<?php }
add_action( 'register_post', 'add_register_field_validate', 10, 3 );
function add_register_field_validate( $sanitized_user_login, $user_email, $errors) {
<?php
$attachments = get_children(
array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_parent' => $post->ID
));
if(count($attachments) > 1) { ?>
<!-- 画像が複数ある場合。スライダー使うとか -->
<?php } else { ?>
<link type="text/css" href="<?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" rel="stylesheet" />
<?php
if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'foo-thumb', 400, 9999 );
add_image_size( 'bar-thumb', 240, 180, true );
} ?>
/*テーマファイルで下記のように記述*/
<?php echo get_the_post_thumbnail($post->ID, 'foo-thumb'); ?>
<?php
if(current_user_can('read_private_pages')) :
?>
//ログインしないと見れない場所
<?php endif; ?>
<?php
function has_thumb_class($classes) {
global $post;
if( has_post_thumbnail($post->ID) ) { $classes[] = 'foo'; }
return $classes;
}
add_filter('post_class', 'has_thumb_class');
?>
<?php
add_action('init', 'foo_custom_init');
function foo_custom_init()
{
$args = array(
'exclude_from_search' => true, // ここでtrueを指定する
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
<?php
function escape_my_code( $attr, $content = null ) {
$content = clean_pre($content);
return '<pre"><code>' .
str_replace('<', '&lt;', $content) .
'</code></pre>';
}
add_shortcode('code', 'escape_my_code');
?>
<?php
function enable_threaded_comments(){
if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
wp_enqueue_script('comment-reply');
}
}
add_action('get_header', 'enable_threaded_comments');
?>