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
The Role of Developer Relations in AI Product Success.
giftojabu1
0
140
Security-JAWS【第35回】勉強会クラウドにおけるマルウェアやコンテンツ改ざんへの対策
4su_para
0
180
Taming you application's environments
salaboy
0
200
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
600
【Pycon mini 東海 2024】Google Colaboratoryで試すVLM
kazuhitotakahashi
2
540
Lambda10周年!Lambdaは何をもたらしたか
smt7174
2
110
Lambdaと地方とコミュニティ
miu_crescent
2
370
アジャイルでの品質の進化 Agile in Motion vol.1/20241118 Hiroyuki Sato
shift_evolve
0
170
EventHub Startup CTO of the year 2024 ピッチ資料
eventhub
0
130
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.2k
Engineer Career Talk
lycorp_recruit_jp
0
190
Introduction to Works of ML Engineer in LY Corporation
lycorp_recruit_jp
0
140
Featured
See All Featured
Navigating Team Friction
lara
183
14k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Gamification - CAS2011
davidbonilla
80
5k
Statistics for Hackers
jakevdp
796
220k
What's new in Ruby 2.0
geeforr
343
31k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Documentation Writing (for coders)
carmenintech
65
4.4k
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 ͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ