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
カメラを用いた店内計測におけるオプトインの仕組みの実現 / ai-optin-camera
cyberagentdevelopers
PRO
1
120
【LT】ソフトウェア産業は進化しているのか? -Javaの想い出とともに- #jjug_ccc
takabow
0
170
visionOSでの空間表現実装とImmersive Video表示について / ai-immersive-visionos
cyberagentdevelopers
PRO
1
100
Aurora_BlueGreenDeploymentsやってみた
tsukasa_ishimaru
1
120
30万人が利用するチャットをFirebase Realtime DatabaseからActionCableへ移行する方法
ryosk7
5
320
独自ツール開発でスタジオ撮影をDX!「VLS(Virtual LED Studio)」 / dx-studio-vls
cyberagentdevelopers
PRO
1
170
Autify Company Deck
autifyhq
1
39k
顧客が本当に必要だったもの - パフォーマンス改善編 / Make what is needed
soudai
24
6.6k
新卒1年目が挑む!生成AI × マルチエージェントで実現する次世代オンボーディング / operation-ai-onboarding
cyberagentdevelopers
PRO
1
160
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
5
49k
生成AIとAWS CDKで実現! 自社ブログレビューの効率化
ymae
2
310
失敗しないOpenJDKの非互換調査
tabatad
0
260
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.1k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
92
16k
What's in a price? How to price your products and services
michaelherold
243
12k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
7.9k
Art, The Web, and Tiny UX
lynnandtonic
296
20k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Designing on Purpose - Digital PM Summit 2013
jponch
115
6.9k
RailsConf 2023
tenderlove
29
880
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 ͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ