Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
ノンプログラマーのためのWordPressループことはじめ
Search
EisukeAkimoto
August 25, 2013
Technology
3
550
ノンプログラマーのためのWordPressループことはじめ
第5回WordBench千葉で発表したスライドです。 #wbchiba
http://andask.net
EisukeAkimoto
August 25, 2013
Tweet
Share
Other Decks in Technology
See All in Technology
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
130
飲食店データの分析事例とそれを支えるデータ基盤
kimujun
0
160
The Rise of LLMOps
asei
7
1.7k
【令和最新版】AWS Direct Connectと愉快なGWたちのおさらい
minorun365
PRO
5
760
TypeScript、上達の瞬間
sadnessojisan
46
13k
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.7k
『Firebase Dynamic Links終了に備える』 FlutterアプリでのAdjust導入とDeeplink最適化
techiro
0
130
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
190
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
950
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
13k
Featured
See All Featured
How STYLIGHT went responsive
nonsquared
95
5.2k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
Writing Fast Ruby
sferik
627
61k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Code Reviewing Like a Champion
maltzj
520
39k
Designing for humans not robots
tammielis
250
25k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Unsuck your backbone
ammeep
668
57k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Transcript
5th WordBench Chiba ϊϯϓϩάϥϚʔͷͨΊͷ 8PSE1SFTT ϧʔϓ͜ͱ͡Ί
5th WordBench Chiba
ࣗݾհ ϑϦʔϥϯεͷΣϒ͞Μ ࠷ۙ 8PSE1SFTT Λ༻͢ΔҊ͕݅ओ ɾίʔϙϨʔτ ɾΞύϨϧ ɾϏϡʔςΟʔɹFUD 5th WordBench
Chiba
5th WordBench Chiba ϒϩά ͋Γ·͢ an d ask.net
ຊͷ͓͠ͳ͕͖ 㾎8PSE1SFTT ʹ͔ܽͤͳ͍ϧʔϓͷॻ͖ํ ᶃ8PSE1SFTT ͷॲཧͷྲྀΕ ᶄRVFSZ@QPTUTͱHFU@QPTUT ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ 5th WordBench
Chiba
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ PC Web Database
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ IUUQFYBNQMFDPN Q ͜ͷ 63- ΞΫηεͨ͠߹
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ 63- Λͱʹσʔλϕʔε͔Β ݅ʹ߹͏ߘσʔλͷऔಘ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ ͜Ε͕8PSE1SFTT ʂ ʂ ͍ͨͬͯγϯϓϧ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ ͭ·Γ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ 63- Λͱʹσʔλϕʔε͔Β ݅ʹ߹͏ߘσʔλͷऔಘ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ Web Web PC Theme Database
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ 63- Λͱʹσʔλϕʔε͔Β ݅ʹ߹͏ߘσʔλͷऔಘ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ ʮIBWF@QPTUT ʯʁ ςʔϚͰσʔλΛܗ
5th WordBench Chiba ᶃ8PSE1SFTTͷॲཧͷྲྀΕ 1$ʮදࣔ͞ΕͨΑʂʂʯ Web
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT RVFSZ@QPTUT ͱ query_posts()
8PSE1SFTT ͕ߘΛදࣔ͢Δͷʹ༻͍ͯ͠ΔϝΠϯΫΤϦʔ Λஔ͖͑ΔखஈͰ͢ɻ͜ΕϝΠϯΫΤϦʔΛҰ୴ԣʹஔ͍͓͖ͯɺ৽͍͠ΫΤϦʔ Ͱ্ॻ͖͠·͢ɻquery_posts Λݺͼग़ͨ͋͠ͱɺΫΤϦʔͷվมΛͨ͢Ίʹɺ wp_reset_query() Λݺͼग़͠ɺΦϦδφϧͷϝΠϯΫΤϦʔΛ෮׆ͤ͞Δඞཁ͕ ͋Γ·͢ɻ தུ query_posts Ͱͳ͘ pre_get_posts ϑΟϧλʔΛ༻͍ɺis_main_query Ͱ νΣοΫͯ͠ϝΠϯΫΤϦʔΛมߋ͢Δ͜ͱ͕ڧ͘ਪ͞Ε͍ͯ·͢ɻ 8PSE1SFTT$PEFYΑΓҾ༻
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT RVFSZ@QPTUT ͱ query_posts()
8PSE1SFTT ͕ߘΛදࣔ͢Δͷʹ༻͍ͯ͠Δ ʠߘσʔλΛ ݺͼग़͢ઃఆ܈ʡ Λஔ͖͑ΔखஈͰ͢ɻ͜Ε ʠσϑΥϧτͰηοτ͞ΕΔઃఆ܈ʡ Λ Ұ୴ԣʹஔ͍͓͖ͯɺ৽͍͠ ʠઃఆʡ Ͱ্ॻ͖͠·͢ɻquery_posts Λݺͼग़ͨ͋͠ ͱɺ ʠมߋ͞Εͨઃఆʡ Λͨ͢Ίʹɺwp_reset_query() Λݺͼग़͠ɺ ʠσϑΥϧ τͷઃఆ܈ʡ Λ෮׆ͤ͞Δඞཁ͕͋Γ·͢ɻ தུ query_posts Ͱͳ͘ pre_get_posts ϑΟϧλʔΛ༻͍ɺis_main_query Ͱ νΣοΫͯ͠ ʠσϑΥϧτͰηοτ͞ΕΔઃఆ܈ʡ Λมߋ͢Δ͜ͱ͕ڧ͘ਪ͞Εͯ ͍·͢ɻ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT ͭ·Γ ʢͲ͏͍͏͜ͱʜʁʣ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT ·ͣɺ63- Λͱʹ ʠσϑΥϧτͰηοτ͞ΕΔઃఆ܈ʡ Λݺͼग़ͯ͠σʔλϕʔε͔Β݅ʹ߹͏ߘσʔλͷऔಘʂ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT query_posts() Ͱʠݺͼग़͞ΕͨઃఆΛ্ॻ͖ͯ͠ʡ σʔλϕʔε͔Β݅ʹ߹͏ߘσʔλͷ ʠ࠶ʡ
औಘʂ มߋͨ͠ޙ wp_reset_query() ͰઃఆΛݩʹ͢ɻͭ·Γͦ͏͍͏͜ͱʂ query_posts()
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT HFU@QPTUTͱ ςϯϓϨʔτλά get_posts() ɺෳͷϧʔϓΛ࡞͢ΔͨΊͷγϯϓϧͳ
λάͰ͢ɻ͜ΕΛͬͯɺ࠷৽ͷߘ݅ʹҰக͢ΔߘΛऔಘ͢Δ͜ͱ͕Ͱ͖ ·͢ɻ 8PSE1SFTT$PEFYΑΓҾ༻
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT HFU@QPTUTͱ ςϯϓϨʔτλά get_posts() ɺෳͷϧʔϓΛ࡞͢ΔͨΊͷγϯϓϧͳ
λάͰ͢ɻ͜ΕΛͬͯɺ࠷৽ͷߘ݅ʹҰக͢ΔߘΛऔಘ͢Δ͜ͱ͕Ͱ͖ ·͢ɻ ͭ·Γɺ ʠσϑΥϧτͰηοτ͞ΕΔઃఆ܈ʡ ɹʹӨڹͤͣϧʔϓΛ࡞͢Δ͜ͱ͕ Ͱ͖·͢ɻ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT αϒϧʔϓ get_posts() ϝΠϯϧʔϓ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT HFU@QPTUT͕దͯ͠Δ໘ ϝΠϯͷϧʔϓͷଞʹɺ৽ͨʹهࣄͷҰཡΛද͍ࣔͤͨ͞ͱ͖ɻ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT HFU@QPTUT͕దͯ͠Δ໘ ϝΠϯͷϧʔϓͷଞʹɺ৽ͨʹهࣄͷҰཡΛද͍ࣔͤͨ͞ͱ͖ɻ ྫ͑ ʮαΠυόʔʹಛఆͷΧςΰϦʔʹଐ͢ΔهࣄΛ̑݅ද͓͖͍ࣔͤͯͨ͞ʯ
ʮαΠυόʔʹਓؾͷ͋ΔهࣄΛ̑݅ද͓͖͍ࣔͤͯͨ͞ʯ ʮಛఆͷߘΛআ͍ͯɺ͓͢͢ΊͷهࣄΛ̍̌݅ද͍ࣔͨ͠ʯ ͳͲͳͲʜ
5th WordBench Chiba ᶄRVFSZ@QPTUT ͱ HFU@QPTUT HFU@QPTUT͕దͯ͠Δ໘ ϝΠϯͷϧʔϓͷଞʹɺ৽ͨʹهࣄͷҰཡΛද͍ࣔͤͨ͞ͱ͖ɻ ྫ͑ ʮαΠυόʔʹಛఆͷΧςΰϦʔʹଐ͢ΔهࣄΛ̑݅ද͓͖͍ࣔͤͯͨ͞ʯ
ʮαΠυόʔʹਓؾͷ͋ΔهࣄΛ̑݅ද͓͖͍ࣔͤͯͨ͞ʯ ʮಛఆͷߘΛআ͍ͯɺ͓͢͢ΊͷهࣄΛ̍̌݅ද͍ࣔͨ͠ʯ ͳͲͳͲʜ ͜͏͍ͬͨ໘Ͱ get_posts() Λ͑ɺ8PSE1SFTT ͕ߦͬͯ͘ΕΔ 63- ʹΑΔσϑΥϧτͷॲཧʹӨڹΛ༩͑ͣɺ༧ظͤ͵ى͜͠ʹ͍͘ϧʔϓͷ ࡞͕Ͱ͖·͢ʂ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ <QSF> ʮ͋Β͔͡Ίʯ ʮʜҎલͷʯ ʮʜͷલ෦ʹ͋Δʯͷҙɻ Ҿ༻ɿHPP
ࣙయ ͋Β͔͡Ί HFU@QPTUT
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ <QSF> ʮ͋Β͔͡Ίʯ ʮʜҎલͷʯ ʮʜͷલ෦ʹ͋Δʯͷҙɻ Ҿ༻ɿHPP
ࣙయ ͋Β͔͡Ί HFU@QPTUT ʊਓਓਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹ͋Β͔͡Ί HFU@QPTUT ʂɹʻ ʉ:?:?:?:?:?:?:?:?:?ʉ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ Web Web Theme Database
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ Web Web Theme Database pre_get_posts
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ Web Web Theme Database pre_get_posts
63- Λͱʹ ʠσϑΥϧτͰηοτ͞ΕΔઃఆ܈ʡ ʹɺߋʹ ʠઃఆΛࢦఆʡ ্ͨ͠Ͱσʔλϕʔε͔Β ݅ʹ߹͏ߘσʔλͷऔಘʂ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ Web Web Theme Database pre_get_posts
query_posts() ͰʠઃఆΛ্ॻ͖ͤͣͱʡ ද͍ࣔͤͨ͞༰ͰهࣄͷҰཡ͕औಘ͞ΕΔʂ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ ͜͜Ͱɺ࣮ࡍͷίʔυΛݟͯ·͠ΐ͏ɻ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ <?php query_posts( array( ’ posts_per_page’
=> 10, ’ post_type’ => ’ post’ , ’ order’ => ’ DESC’ , ) ); while( have_posts() ): the_post(); …
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ ’ posts_per_page’ => 10 ’
post_type’ => ’ post’ ’ order’ => ’ DESC’
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ <?php function wbchiba_get_posts($query) { if(
is_admin() || !$query->is_main_query() ) return; if ( $query->is_home() ) { $query->set(’ posts_per_page’ => 10 ); $query->set(’ post_type’ => ’ post’ ); $query->set(’ order’ => ’ DESC’ ); } } add_action(’ pre_get_posts’ , ’ wbchiba_get_posts’ ); ?>
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ ༻Ͱ͖Δύϥϝʔλʔɺ81@2VFSZ ͱಉ͡Ͱ͢ɻ ࠓ·Ͱ࣮ࡍʹ༻͢ΔςϯϓϨʔτʹ query_posts() ͱॻ͍ͯࡏ͠
͍ͯͨʮΫΤϦʔͷΧελϚΠζʯ͕ɺGVODUJPOTQIQ ʹͯ pre_get_ posts ͷઃఆΛߦ͏͜ͱͰɺ8FC αΠτશମͷϝΠϯϧʔϓΛཧ͢Δ ͜ͱ͕ՄೳͰ͢ɻ ͜ͷํ๏ʹ׳Ε͓ͯ͘ͱɺσʔλϕʔεʹ༏͘͠ແବͷগͳ͍ςϯϓϨ ʔτ࡞͕Մೳʹʂʂ ༰ͷཧղ·Ͱ͠ͳ͘ͱɺ·ͣखΛಈ͔ͯ͠ pre_get_posts ͷ ΜΓ͞Λ࣮ײͯ͠Έ·͠ΐ͏ʂʂ
5th WordBench Chiba ᶅQSF@HFU@QPTUT ͬͯͳΜͩʁ ίϐϖϓϩάϥϚʔଔۀͷۙಓ ·ͣखΛಈ͔͢͜ͱ͔Βʂ
5th WordBench Chiba ࢀߟʹ͍͍ͤͯͨͩͨ͞هࣄ 8PSE1SFTT ͰϖʔδૹΓ͕ಈ͔ͳ͍ͷͲ͏ߟ͑ͯ RVFSZ@QPTUT ͕ѱ͍ ʲQSF@HFU@QPTUTɺ8PSE1SFTT ϧʔϓ·ͱΊʳ
IUUQOPUOJMDSFBUJWFDPNCMPHBSDIJWFT ϓϥάΠϯ"1* ΞΫγϣϯϑοΫҰཡ QSFHFUQPTUT IUUQXQEPDTTPVSDFGPSHFKQ ϓϥάΠϯ @"1* ΞΫγϣϯϑοΫ Ұཡ QSF@HFU@QPTUT
5th WordBench Chiba ͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ