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-serverless-architecture-we-dreamed-of
tomoki10
0
460
なぜCodeceptJSを選んだか
goataka
0
160
Amazon SageMaker Unified Studio(Preview)、Lakehouse と Amazon S3 Tables
ishikawa_satoru
0
160
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
850
フロントエンド設計にモブ設計を導入してみた / 20241212_cloudsign_TechFrontMeetup
bengo4com
0
1.9k
KnowledgeBaseDocuments APIでベクトルインデックス管理を自動化する
iidaxs
1
270
終了の危機にあった15年続くWebサービスを全力で存続させる - phpcon2024
yositosi
17
16k
Wantedly での Datadog 活用事例
bgpat
1
520
多領域インシデントマネジメントへの挑戦:ハードウェアとソフトウェアの融合が生む課題/Challenge to multidisciplinary incident management: Issues created by the fusion of hardware and software
bitkey
PRO
2
110
PHPerのための計算量入門/Complexity101 for PHPer
hanhan1978
5
200
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
0
210
20241220_S3 tablesの使い方を検証してみた
handy
4
620
Featured
See All Featured
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
GraphQLとの向き合い方2022年版
quramy
44
13k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Keith and Marios Guide to Fast Websites
keithpitt
410
22k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
247
1.3M
Writing Fast Ruby
sferik
628
61k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Gamification - CAS2011
davidbonilla
80
5.1k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
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 ͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ