Wordbench長野〜WordPress初心者の為のPHP入門とjQuery話〜
- 7. 変数
$hoge
「入れ物」です。
頭に$が付くので見分けやすい
文字や数字や、、色々入ります。
$title = get_the_title( );
- 8. 変数
$hoge
「入れ物」です。
頭に$が付くので見分けやすい
文字や数字や、、色々入ります。
$title = get_the_title( );
タイトルが入る
- 9. 関数
echo()
処理(仕事)をする
後ろに()が付く
どんな処理をするかは、Googleで
調べる☆(ゝω・)
$title = get_the_title( );
- 10. 関数()の中の物を表示する
echo()
処理(仕事)をする
後ろに()が付く
どんな処理をするかは、Googleで
調べる☆(ゝω・)
$title = get_the_title( );
タイトルを教えてくれる
- 11. 代入
$title = get_the_title( );
等しい という意味ではないので注意!
- 14. 軽くおさらい
<html>
<h1>
<?php
<html>
$title = get_the_title( );
<h1>タイトルー</h1>
echo($title);
</html>
?>
</h1>
</html>
- 15. ''(クオート)""
数字 : 9
文字 : '字'
シングルクオーテーション → ' '
ダブルクオーテーション → " "
- 16. ''(クオート)""
数字 : 9
文字 : '字'
シングルクオーテーション → ' '
ダブルクオーテーション → " "
←コレはエラーになる!
- 17. 算数
かけ算
引き算 3*2
3-2 割り算
足し算 3/2
3+2 割り算
余無し
3%2
- 18. 算数
かけ算 6
引き算 3*2
1
3-2 割り算 1.5
足し算 3/2
5
3+2 割り算
余無し 1
3%2
- 22. 比較
2<3
3>2
2=<3
これが 等しい
3=>2
3==3
- 24. if
if ( $title == 'タイトルー') :
echo('変なタイトルw');
endif;
ifの()の中が
true(OKな状態)
だったら
endif;
までの間を実行する
- 27. いろんなifの書き方
if ( $hoge == '?' ) :
echo('さっきの奴∼');
endif;
if ( $hoge == '?' ) {
echo('波カッコで囲う');
}
if ( $hoge == '?' )
echo('この一行だけ実行されます');
- 32. whileの色んな書き方
発音 : w l
while ( ) :
echo('end何とかの奴∼');
endwhile;
while ( ) {
echo('やっぱり波カッコの奴∼');
}
- 42. 確認用ツール
• Firefox
• ブラウザー、Win/Mac
• Firebug
• Firefoxに入れる拡張機能
• CSSからJavascriptまで、コレが無
いとお仕事できません
- 45. いいね!ボタン
コード取得ページ
http://developers.facebook.com/docs/
reference/plugins/like/
- 46. single.php サンプルテキスト
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=150015455104429";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<nav id="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">←</span> Previous', 'twentyeleven' ) ); ?></span>
<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></span>
</nav><!-- #nav-single -->
<?php get_template_part( 'content', 'single' ); ?>
<!-- いいね!ボタン -->
<div class="fb-like" data-href="<?php echo( the_permalink() );?>" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>
<!-- いいね!ボタン終わり -->
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
- 51. WordPressならではの注意点
いきなり$が使えない
ここで、$をローカル変数
としてセットする事により
$が使えるようになる
jQuery(document).ready(function($){
$('#id').fadeIn();
});
- 58. single.php サンプルテキスト
<?php wp_enqueue_script('jquery'); ?>
<?php
/**
* The Template for displaying all single posts.
*
* @package WordPress
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
get_header(); ?>
<style>
.post{
display: none;
}
</style>
<script>
jQuery('.post').ready(function($){
$('.post').fadeIn(10000);
});
</script>
<div id="primary">
<div id="content" role="main">
<?php while ( have_posts() ) : the_post(); ?>
<nav id="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'twentyeleven' ); ?></h3>
<span class="nav-previous"><?php previous_post_link( '%link', __( '<span class="meta-nav">←</span> Previous', 'twentyeleven' ) ); ?></span>
<span class="nav-next"><?php next_post_link( '%link', __( 'Next <span class="meta-nav">→</span>', 'twentyeleven' ) ); ?></span>
</nav><!-- #nav-single -->
<?php get_template_part( 'content', 'single' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_footer(); ?>
Editor's Notes
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- <div id="fb-root"></div>\n<script>(function(d, s, id) {\n var js, fjs = d.getElementsByTagName(s)[0];\n if (d.getElementById(id)) return;\n js = d.createElement(s); js.id = id;\n js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1&appId=150015455104429";\n fjs.parentNode.insertBefore(js, fjs);\n}(document, 'script', 'facebook-jssdk'));</script>\n\n<div class="fb-like" data-href="http://172.16.45.128/" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false"></div>\n\n<?php echo the_permalink();?>\n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n
- \n