ini_set('error_reporting', E_ALL | ~E_STRICT);
# <? ?> is allowed
php_flag short_open_tag On
/**
* Template Name: Name
*/
<a href="<?php echo esc_url(home_url('xxx/')); ?>">
# image path
<img src="<?php echo esc_url(get_template_directory_uri()); ?>/img/common/header/logo.png">
# /var/www/html/example/wp-content/themes/twentyten
get_template_directory()
# include template
get_template_part('container', 'xxx');
$isDevelopment = strpos( $_SERVER["HTTP_HOST"], "localhost" ) !== false;
<?php
if ( date( 'U' ) - get_the_time( 'U', $post->ID ) < 24 * 60 * 60 * 30 ):
?>
<span class="label label-red">NEW</span>
<?php
endif;
?>
https://developer.wordpress.org/themes/basics/template-hierarchy/
https://developer.wordpress.org/files/2014/10/wp-hierarchy.png
https://codex.wordpress.org/Template_Tags/get_posts#Access_all_post_data
<?php
global $post;
$lastposts = get_posts( array(
'posts_per_page' => 3,
'post_type' => 'news',
) );
foreach ( $lastposts as $post ) :
setup_postdata( $post ); ?>
<h2>
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h2>
<?php the_content(); ?>
<?php
endforeach;
wp_reset_postdata();
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
CATEGORIES
</h3>
</div>
<div class="list-group">
<?php
$categories = get_categories();
foreach ( $categories as $category ) {
?>
<a href="<?php echo get_category_link( $category->term_id ); ?>" class="list-group-item">
<?php
echo $category->name;
?>
<span class="badge">
<?php
echo $category->category_count;
?>
</span>
</a>
<?php
}
?>
</div>
</div>
/*
*
---------------------------------------------------------*/
function my_excerpt_length( $length ) {
return 80;
}
add_filter( 'excerpt_length', 'my_excerpt_length' );
jQuery(document).ready(function( $ ) {
$('.element').on('click', function() {
$(this).hide();
})
});
[contact-form-7 id="1234" title="Contact form 1" html_id="contact-form-1234" html_class="container-form"]
<?php the_widget( 'bizcalendarwidget' ); ?>
echo get_the_title( get_option('page_for_posts', true) );
post_type_archive_title();
// Category
$cat = get_the_category();
$catId = $cat[0]->cat_ID;
$catName = $cat[0]->name;
$catSlug = $cat[0]->category_nicename;
$link = get_category_link($catId);
// Custom post category(taxonomy)
$category = get_the_terms( $post->ID, 'product-category' );
$catName = $category[0]->name;
https://setting-tool.net/wordpress-p-br-auto-format
<?php
if ( '' !== get_the_post_thumbnail() ) :
?>
<p>
<?php
the_post_thumbnail( 'post-thumbnail', array(
'class' => 'img-responsive'
) );
?>
</p>
<?php
endif;
?>
// title
echo mb_strimwidth(get_the_title(), 0, 60, "...", "UTF-8");
// content
$content = wp_strip_all_tags( get_the_content() );
echo nl2br(mb_strimwidth($content, 0, 100, "...", "UTF-8"));
<?php
get_header();// get header.php
get_footer();// get footer.php
wp_head();
wp_footer();
<body <?php body_class(); ?>>
$post_type = get_query_var( 'post_type' );// if custom post type.
var_dump($post_type);
<ul class="nav navbar-nav">
<li<?php echo (is_home()) ? ' class="active"' : ''; ?>>
<a href="<?php echo esc_url(home_url('/')); ?>">
<img src="<?php echo esc_url(get_template_directory_uri()); ?>/img/nav/top.png" alt="トップページ TOP">
</a>
</li>
<li<?php echo ($post_type == 'products') ? ' class="active"' : ''; ?>>
<a href="<?php echo esc_url(home_url('products/')); ?>">
echo do_shortcode('[addtoany]');
https://ja.wordpress.org/plugins/custom-field-suite/ (can connect Page template name)
http://qiita.com/wonda/items/ee33ec26028e52cf9336
require_once('../wp-blog-header.php');
http://qiita.com/OJI3T/items/f3cd1219cb722b0c7eb8
https://gist.github.com/regepan/6d9767fd56339d4bdfe501aad14cfde3
https://codex.wordpress.org/Resetting_Your_Password#Through_MySQL.2FMariaDB_Command_Line
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ https://interconnectit.com/blog/2009/10/07/migrating-a-wordpresswpmubuddypress-website/
https://nskw-style.com/2014/wordpress/wordpress-app-with-rewrite-api.html