Unlimited $1.99 domain names - We use goDaddy 無制限の$ 1.99のドメイン名-私たち使用のG oDaddy
Powered by MaxBlogPress 電源をmaxblogpress

WordPressのハック# 1 -q uery_posts| j tprattのブログミス
jtprattのブログミス


Home » Wordpress Hack #1 - query_posts » WordPressのハック# 1 -q uery_posts



Wordpress Hack #1 - query_posts WordPressのハック# 1 -q uery_posts

434 views - 434再生回数-著

Posted in: に投稿された:

ブログ-セットアップの作成カテゴリのイメージWordPressのカテゴリのイメージ
434 views 434再生回数


Please note: This page was originally written in English.ご注意ください:このページは、もともと英語で書かれています。

The original post can be viewed表示できるよう、元の投稿 hereここで .です。

Please note: This page was originally written in English.

The text has been translated using an online service such as Google or Babelfish.

The original post can be viewed here.


This is the very first post in theこれは、非常に最初の投稿は、 30 Wordpress Hacks in 30 Days Series 30日の30日間のWordPressのhacksシリーズ !

If you use Wordpress - then this is a series you will want to bookmark right now!を使用する場合のWordPress -入力し、これは、シリーズをブックマークに飲まれることを今すぐ! You might even want to subscribe by email at the top of the page.あなたもしたいかもしれない電子メールを購読するには、ページの上部にします。 If you’re like me your sick and tired of googling the crap out of the web trying to find easy ways to hack and customize your Wordpress blog or web site.私しているような場合に飽き飽きしてgooglingのでびびったしようとして、ウェブを検索する方法を簡単にハッキングしたり、カスタマイズしてWordPressのブログやウェブサイトです。 I’m going to give you a very useful and easy to perform Wordpress hack every day for a month!を与えるつもりだが、非常に有効なWordPressのハッキングを実行すると簡単にするために毎日月日! I think that it’s easier to do something like this than write a humongous post with more information than you’ll never read or digest in one sitting.私が思うに、何かを簡単にこのような基本的にでかいよりもここにいつまでたっても他の情報を1つのダイジェスト座って読んだりします。 Instead I’m going to give you one very simple and easy task to do each and every day.を与える代わりに行くんだと非常に単純なものを1つの簡単なタスクを行う連日です。 Depending on your skill level, you may or may not want to take a look at last week’s postあなたの技能レベルに応じて、したいことができないことがありますかを見て、先週のポスト How to Create Your Own Wordpress Theme 自分のWordPressのテーマを作成する方法 .です。

Wordpress Hack #1 - query_posts WordPressのハック# 1 -q uery_posts

Today in our very first Wordpress Hack in our 30-day “Hack-a-thon” we’re going to learn about the Wordpress “template tag” query_posts.今日、私たちは非常に最初の30日間のWordPressのハック"ハック-討論"われわれは行くの詳細については、 WordPressの"テンプレートタグ" query_postsです。 You canすることができます。 read about query_posts in the Wordpress Codex here読み取りについては、ここquery_postsは、 WordPressのコーデックス .です。 To use any of these examples you must place the PHP code snippet before “the loop”.これらの例を使用するのは、 PHPコードスニペットを配置する必要があります前に"ループ"です。 If you don’t know what “the loop” is, just follow the link in the previous paragraph to create your own wordpress theme for an explanation.がわからない場合は、どのような"ループ"は、下記のリンクをクリックして前の段落を作成して、 WordPressのテーマを説明します。 Each and every code snippet can used any any page that uses “the loop”, such as your index.php, category.php, archive.php, tag.php, or search.php.各コードスニペットは、使用される任意の任意のページを使用して、 "ループ"など、 index.phpを、 category.php 、 archive.php 、 tag.phpか、またはsearch.phpです。

Exclude posts that belong to a category 除外の記事を参照して作成カテゴリに属する

Maybe you don’t want posts from a certain category showing up on your index or another archive page.たぶんしない場合は、特定のカテゴリの表示中の記事を上からして、インデックスまたは別のアーカイブページをご覧ください。 You could even use this to keep certain categories from showing in search results if you needed to.これを維持することも使用する特定のカテゴリの検索結果を表示する場合に必要です。 You need to know your category “ID” to do this, just retrieve it from your dashboard under “Manage->Categories”, and the “-1″ with your category ID# like this…あなたのカテゴリを知ってする必要があります。 "番号"これを行うには、ダッシュボードの下から取得しようとして"管理- >カテゴリー" 、および" -1 "としてカテゴリID #のように…

 <?php query_posts('cat=-1'); ?> <ですか? PHPのquery_posts ( '猫=- 1 ' ) ;ですか? > 

You can exclude multple categories like this…複数のカテゴリーを除外することができますように…

 <?php       query_posts("cat=-1,-2,-3"); ?> <ですか? PHPのquery_posts ( "猫=- 1 、 -2 、 -3 " ) ;ですか? > 

Retrieve a Post or Page 郵便またはページを取得する

To retrieve a particular post you can either call it by ID (listed in your dashboard) or it’s slug like this (use one line of code or the other, not both)…を取得する、特定のいずれかを呼び出すことによって作成することができます番号(ダッシュボードに記載されて) 、またはそれのナメクジのように( 1つのコード行を使用したり、他のではなく、その両方) …

 <?php query_posts('p=1'); //using post id query_posts('name=first-post'); //using post slug ?> <ですか? PHPのquery_posts ( ' p = 1 ' ) ; / /郵便番号を使用してquery_posts ( '名=最初の投稿' ) ; / /スラグを使用しての投稿ですか? > 

You can do the same thing to retrieve pages as well like this…同じことをすることができますを取得するページには、このようとしても…

 <?php query_posts('page_id=7'); //retrieves page 7 only query_posts('pagename=about'); //retrieves the about page only ?> <ですか? PHPのquery_posts ( ' page_id = 7 ' ) ; / / 7ページのみを取得query_posts ( 'ページ名=約' ) ; / /取得して約ページのみですか? > 

When you use those examples it retrieves the entire post.これらの例を使用する場合はそれ全体を取得して作成します。 When you are notorious for writing extremely long posts (like I am) you may only want to get a partial post with the “read more” link.悪名高いときには極端に長い記事を書く(私のような)ことがあります部分のみを取得するには、基本的に、 "続きを読む"リンクをクリックします。 This is especialy useful if you’re going ot feature certain posts on your index or other pages.これはotマークI便利な機能に行くなら、特定の投稿をして、インデックスや他のページをご覧ください。 Here’s the code for that…ここでのコードは、その…

 <?php query_posts('p=5'); //get post with id of 5 global $more; $more = 0; //gets partial post with read more link ?> <ですか? PHPのquery_posts ( ' p = 5 ' ) ; / / idを取得後5グローバル$他; $他= 0 ; / /ジェ続きを読むリンクを作成部分ですか? > 

You know that you can create pages, and you can also create “child pages” like I have on ths site.知っているページを作成することができますし、作成することもできます"子ページ"のように私はthsサイトです。 I have a parent page called “series”, and then all the individual series index pages are children of that page.私には親ページと呼ばれる"シリーズ" 、と入力し、すべての子供たちの個々のシリーズのインデックスページは、そのページをご覧ください。 If you want to get a child page - that’s possible as well, but you can’t call it by id - you have to call it by double-slug as in the example below (parent slug slash child slug).子供を取得するにする場合は、ページ-それが可能になりましたが、それをコールすることはできません番号-必要がナメクジを呼び出すことをダブル以下の例のように(スラッシュの子供の親スラグスラグ)です。

 <?php query_posts('pagename=parent/child'); ?> <ですか? PHPのquery_posts ( 'ページ名=親/子' ) ;ですか? > 

Retrieve Post by Certain Authors 投稿者の特定の作家を取得

If your blog has multiple authors you can retrive them by name or author id like this…あなたのブログの場合は、それらを取得することができます。複数の投稿者の名前や著者番号のように…

 <?php query_posts('author_name=John'); query_posts('author=3'); ?> <ですか? PHPのquery_posts ( 'のAUTHOR_NAME =ジョン' ) ; query_posts ( '著者= 3 ' ) ;ですか? > 

Retrieve Every Single Post 取得するごとに1つのポスト
Maybe you want to make some kind of an archive page or sitemap.おそらくいくつかの種類を指定して、アーカイブページやサイトマップです。 Whether or not you create a page with this query of course depends on how many posts you really have, but inserting this code before the loop will list ever post you have all on one page.ページを作成するかどうかはもちろん、このクエリに依存して多くの記事をどのように実際は、しかし、このコードを挿入する前にループが表示さまで作成に必要なすべてを1つのページをご覧ください。 While the code below shows all posts on one page, you can change the “-1″ to just 1 post, or 5, or 10, or however many posts you want to display.すべての記事を示しながら以下のコードを1つのページで、変更することができます" -1 "をわずか1件の投稿、または5か、または10か、またはしかし多くの記事を表示したいです。

 <?php query_posts('posts_per_page=-1'); ?> <ですか? PHPのquery_posts ( ' posts_per_page =- 1 ' ) ;ですか? > 

Change the Order or Sequence of Posts 配列の順序を変更したり記事を
By default a Wordpress blog shows you posts in a journal fashion or reverse date order.デフォルトではWordPressのブログの投稿を表示する、または逆日付順ファッション誌です。 You could choose to instead sort your posts by author or title like this.あなたが選択して自分の投稿を著者の代わりに並べ替えやタイトルのようにします。 You could use either the author or title lines.使用することができ、著者やタイトル行のいずれかです。

 <?php query_posts('orderby=author'); query_posts('orderby=title'); ?> <ですか? PHPのquery_posts ( '並べ替え=著者' ) ; query_posts ( '並べ替え=タイトル' ) ;ですか? > 

Using “orderby” there are many different parameters that you can use like these…を使用して"並べ替え"には多くの異なるパラメータを使用することができますように…

* orderby=author *並べ替え=著者
* orderby=date *並べ替え=日付
* orderby=category *並べ替え=カテゴリ
* orderby=title *並べ替え= >標題
* orderby=modified *並べ替え=更新
* orderby=menu_order *並べ替え= menu_order
* orderby=parent *並べ替え=親
* orderby=ID *並べ替え=番号
* orderby=rand *並べ替え=ランド

Retrieve a Post by Time Period 投稿者の期間を取得する

There are many different ways to consruct a query to retrieve certain posts based by date only. consructにはさまざまな種類のクエリを取得する方法をベースに、特定の日付の記事のみです。 Here’sa way to get them for a day of the month…以下の方法を取得して今月の一日…

 <?php query_posts('day=15'); //all posts on the 15th ?> <ですか? PHPのquery_posts ( '日= 15 ' ) ; / /すべての記事は15日ですか? > 

You could also get them for the current month and year with a query like this…それらを取得することもできますし、現在の月の年に、クエリのように…

 <?php $current_month = date('m'); ?> <?php $current_year = date('Y'); ?>  <?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?> <ですか? PHPの$ current_month =日( ' M 'の) ;ですか? > <ですか? PHPの$ current_year =日( ' y 'を) ;ですか? > <ですか? PHPのquery_posts ( "猫= 22 &年= $ current_year & monthnum = $ current_month &オーダー=昇順" ) ;ですか? > 

Retrieve Posts based on Tags タグの記事に基づいて取得する
You can retrieve posts for a specific tag or tags like this (use one line of code at a time only).の記事を取得することができます。は、特定のタグまたはタグのように(使用のコードの行を一度に1つのみ) 。 The first line retrieves posts with a particular tag, the second line is the format for getting posts for multiple tags, but the third line is for getting posts that were tagged in multiple categories.記事の最初の行には、特定のタグを取得、 2番目の行が取得するための形式の記事を複数のタグ、しかし、 3行目はタグを取得された記事を複数のカテゴリーです。 In other words the second line will retrieve all posts tagged as bread all posts tagged as baking.言い換えれば2番目の行はすべての記事を取得するすべての記事をタグとしてタグ付けさベーキングパンです。 But the third line will get only posts tagged in bread and baking and recipe.しかし、 3行目は、タグ付きの記事を取得するだけでパンとパン焼きとレシピです。

 <?php query_posts('tag=cooking'); query_posts('tag=bread,baking'); query_posts('tag=bread+baking+recipe'); ?> <ですか? PHPのquery_posts ( 'タグ=料理' ) ; query_posts ( 'タグ=パン、ベーキング' ) ; query_posts ( 'タグ=パン+パン焼き+レシピ' ) ;ですか? > 

I hope this helps you do a little Wordpress “theme hacking” and customize your blog.といいこれにより、少しお持ちのWordPress "のテーマハッキング"とあなたのブログをカスタマイズします。 If you have any questions about query_posts please comment now, and we’ll see your tomorrow for the next hack!ご質問があればごquery_postsについてコメントする、と私たちに明日を参照して、次のハック!


Tags:タグ: , ,

4 Responses to “Wordpress Hack #1 - query_posts” 4つの応答を" WordPressのハック# 1 -q uery_posts"

  1. Mark Wilson マークウィルソン Has the following to say...には、以下のように言ってやるが...

    I had actually been looking for the one about authors.私は実際には1つの会社を探して、作者に帰属します。
    thanks a lot, it been a big help.どうもありがとう、それが大きな助けです。

    Mark Wilson’s last blog post.. マークウィルソンの最後のブログに投稿.. I hate the word “niche” 私嫌いな言葉"ニッチ"

  2. Make Money Blogging 金を稼ぐブログ Has the following to say...には、以下のように言ってやるが...

    Loving the idea even though this one is sort of irrelevant for me, cannot wait for the rest.愛するというアイデアにもかかわらず、この1つは、並べ替えの低い私にとって、残りのを待つことはできません。

  3. Erika エリカ Has the following to say...には、以下のように言ってやるが...

    Okay… as a wordpress newbie (but someone who chose to dive head-first into WP development… silly me) I can’t tell you how much I value this series that you’re doin!わかりました…としてWordPressの初心者(ただし、 who選択して急降下する第一の頭をWPの開発…愚かな私)私言うことができないことをどのくらい私の値このシリーズことをお詫び申し上げますdoin ! Once I finally get my blog up and running, I’m going to have to toss out a thank-you for helping me so much!やっと私のblog一度取得すると実行中に、私は君を放り出すには、よろしくお願い申し上げます手伝ってくれよ!

  4. admin 管理者 Has the following to say...には、以下のように言ってやるが...

    @Erika - glad to help! @エリカ-うれしいを助けて! I love comments like this, because it means I made the right decision in starting this series…愛しのコメントをこのように、という意味のため右側の意思決定の開始を私はこのシリーズ… =

Question or Comment??質問やコメントですか?ですか? Spill it Now...今すぐ流出...

ジャンプして喜ぶ以上のコメントを!

We Reward Comments!私たちの報酬のコメントを!


We dofollow links, and get your latest blog post as a byline under every new comment from the "CommentLuv" plugin!私たちdofollowリンク、および取得して最新のブログの投稿ごとに新しいコメントとして署名されてからの" commentluv "差込式! Top commenters for every month are listed on every page of this site in a sidebar widget linked back to your URL!トップへの毎月のcommentersは、すべてのページに上場して、サイドバーのウィジェットは、次のサイトでリンクしてURLを省略して! We would like to reward you for becoming part of our community!私たちの希望になる部分に報奨金を弊社のコミュニティ! Your comment is valuable not only to us, but also all the other readers of this blog!あなたのコメントは貴重な情報だけでなく、他のすべてのだけでなく、このブログの読者の!


Click to add smilies to your post! 顔をしてポストをクリックして追加! == [ ]^ = (= ( (= ( |= )研究= | 8= 0= ) 〜= 00= (= ; ;= ) ]= ; ; ;