Host Unlimited Web Sites for Only $10 per Month! استضافة المواقع على شبكة الانترنت لغير محدودة فقط 10 دولار في الشهر!
Powered by MaxBlogPress تصميم maxblogpress

WordPress المأجور # 1 -- query_posts | jtpratt للاخطاء المدونات
Jtpratt للاخطاء المدونات


Home المنزل » Wordpress Hack #1 - query_posts »WordPress المأجور # 1 -- query_posts



Wordpress Hack #1 - query_posts WordPress المأجور # 1 -- query_posts

451 views - 451 اراء --

Posted in: نشر في :

بلوق - اعداد فئة الصورةالفئة صورة WordPress
451 views 451 اراء


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 WordPress المأجورون في 30 يوما سلسلة !

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. واعتقد انه أصبح من السهل ان تفعل شيئا مثل هذا من كتابة ما بعد humongous مع معلومات اكثر مما لن تضطر ابدا قراءة في خلاصة واحدة او الجلوس. Instead I’m going to give you one very simple and easy task to do each and every day. وبدلا من أنا ذاهب الى ان نعطيكم واحد بسيط جدا ومهمة سهلة ان تفعل كل يوم. 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 -- query_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. ونحن اليوم في أول WordPress المأجور في 30 يوما "الماجور - أ - thon" نحن ذاهبون الى معرفة 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”. لاستخدام اي من هذه الامثله يجب ان تضع بي. اتش. بى القصاصه قبل "الحلقه". 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" الخاصة بك مع رقم تعريف فئة # مثل هذا…

 <?php query_posts('cat=-1'); ?> <؟ بي. اتش. بى query_posts ( 'القط =- 1') ؛؟> 

You can exclude multple categories like this… يمكنك ان تستبعد فئات مثل هذا multple…

 <?php       query_posts("cat=-1,-2,-3"); ?> <؟ بي. اتش. بى 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)… لاسترجاع وظيفة معينة يمكنك اما الدعوة اليها من الهوية (المدرجه في لوحة) او انها الدوده البزاقه مثل هذا (استخدام خط واحد للقانون او لآخر ، وليس على حد سواء)…

 <?php query_posts('p=1'); //using post id query_posts('name=first-post'); //using post slug ?> <؟ بي. اتش. بى query_posts ( 'ف = 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 ?> <؟ بي. اتش. بى query_posts ( 'page_id = 7') ؛ / / يسترجع الصفحه 7 فقط query_posts ( 'عن pagename =') ؛ / / يسترجع عن الصفحه فقط؟> 

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. وهذا هو especialy مفيدة اذا كنت الذهاب ت. الميزه وظائف معينة على الرقم القياسي الخاص بك او صفحات أخرى. 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 ?> <؟ بي. اتش. بى query_posts ( 'ف = 5') ؛ / / للحصول على وظيفة مع معرف من 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'); ?> <؟ بي. اتش. بى query_posts ( 'pagename = الأم / الطفل') ؛؟> 

Retrieve Post by Certain Authors استعادة وظيفة من قبل بعض المؤلفين

If your blog has multiple authors you can retrive them by name or author id like this… اذا كان جهازك بلوق متعددة المؤلفين يمكنك retrive لهم اسم او هوية صاحب البلاغ مثل هذا…

 <?php query_posts('author_name=John'); query_posts('author=3'); ?> <؟ بي. اتش. بى query_posts ( 'جون AUTHOR_NAME =') ؛ query_posts ( 'المؤلف = 3') ؛؟> 

Retrieve Every Single Post استرجاع كل وظيفة واحدة
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. أو ما اذا كانت لا تقوم بإنشاء صفحة استعلام وبطبيعة الحال هذا يعتمد على عدد الوظائف التي كنت حقا لها ، ولكن إدخال هذا القانون قبل ان الحلقه ستكون قائمة لديك من اي وقت مضى بعد كل صفحة واحدة. 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 ، او 5 ، أو 10 ، أو غير ان العديد من الوظائف التي تريد عرضها.

 <?php query_posts('posts_per_page=-1'); ?> <؟ بي. اتش. بى 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'); ?> <؟ بي. اتش. بى query_posts ( 'المؤلف orderby =') ؛ query_posts ( 'orderby = العنوان') ؛؟> 

Using “orderby” there are many different parameters that you can use like these… باستخدام "orderby" هناك العديد من المعالم المختلفة التي يمكنك استخدام مثل هذه…

* orderby=author * المؤلف orderby =
* orderby=date * تاريخ orderby =
* orderby=category * فئة orderby =
* orderby=title * عنوان orderby =
* orderby=modified * تعديل orderby =
* orderby=menu_order * Orderby = menu_order
* orderby=parent * Orderby = الأم
* orderby=ID * Orderby = هوية
* orderby=rand * Orderby = راند

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 ?> <؟ بي. اتش. بى query_posts ( 'يوم = 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"); ?> <؟ بي. اتش. بى current_month = دولار حتى الآن ( 'م') ؛؟> <؟ بي. اتش. بى current_year = دولار حتى الآن ( 'y') ؛؟>بي. اتش. بى query_posts ( "القط = 22 سنة & & current_year دولار = = monthnum دولار من اجل current_month & = ASC") ؛ ؟> 

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). يمكنك استرجاع وظائف لفئة معينة او العلامات مثل هذا (استخدام خط واحد للقانون في وقت فقط). 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. السطر الاول يسترجع وظائف معينة مع العلامه ، السطر الثاني هو نموذج للحصول على وظائف متعددة للعلامات ، ولكن السطر الثالث هو للحصول على الوظائف التي كانت علامات في فئات متعددة. In other words the second line will retrieve all posts tagged as bread all posts tagged as baking. وبعباره اخرى في السطر الثاني سوف تستعيد جميع الوظائف الموسومه كالخبز جميع الوظائف الموسومه كما الخبز. But the third line will get only posts tagged in bread and baking and recipe. غير ان الخط الثالث سوف تحصل على وظيفة المعلمه فقط في الخبز والخبز وصفه.

 <?php query_posts('tag=cooking'); query_posts('tag=bread,baking'); query_posts('tag=bread+baking+recipe'); ?> <؟ بي. اتش. بى 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 -- query_posts"

  1. Mark Wilson مارك ويلسون Has the following to say... وقد ما يلي...

    I had actually been looking for the one about authors. انا بالفعل تبحث عن واحد عن المؤلفين.
    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. المحبة للفكرة واحدة على الرغم من ان هذا النوع غير ذي صلة بالنسبة لي ، لا يمكن ان ينتظر لبقية.

  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 مبتدئ) ولكنه اختار شخص من الغوص في اول رئيس رزمه العمل - التنمية سخيف لي…) لا استطيع ان اقول لكم كم انا اقدر قيمة هذه السلسله انك 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! وبمجرد ان أحصل على بلدي اخيرا بلوق وعاملة ، وانا ذاهب الى ان ارم بها الشكر لكم لمساعدة لي الكثير!

  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 كل شهر لترد على كل صفحة من هذا الموقع في الشريط الجانبي القطعه ربط عودة الى عنوان موقعك! 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=)= ؛ ؛=)]= ؛ ؛ ؛