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
C++26 エラー性動作
faithandbrave
2
780
PHPからGoへのマイグレーション for DMMアフィリエイト
yabakokobayashi
1
170
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
0
150
統計データで2024年の クラウド・インフラ動向を眺める
ysknsid25
2
850
1等無人航空機操縦士一発試験 合格までの道のり ドローンミートアップ@大阪 2024/12/18
excdinc
0
170
Oracle Cloudの生成AIサービスって実際どこまで使えるの? エンジニア目線で試してみた
minorun365
PRO
4
290
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
230
OpenAIの蒸留機能(Model Distillation)を使用して運用中のLLMのコストを削減する取り組み
pharma_x_tech
4
570
20241220_S3 tablesの使い方を検証してみた
handy
4
630
Turing × atmaCup #18 - 1st Place Solution
hakubishin3
0
490
PHP ユーザのための OpenTelemetry 入門 / phpcon2024-opentelemetry
shin1x1
1
510
kargoの魅力について伝える
magisystem0408
0
210
Featured
See All Featured
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
The Language of Interfaces
destraynor
154
24k
Visualization
eitanlees
146
15k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
How GitHub (no longer) Works
holman
311
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.2k
GraphQLとの向き合い方2022年版
quramy
44
13k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
A Modern Web Designer's Workflow
chriscoyier
693
190k
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 ͝ਗ਼ௌ͍͖ͨͩ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ