Posted in: Posted in:
432 views 432 opinioni
Please note: This page was originally written in English. Nota: Questa pagina è stata scritta originariamente in lingua inglese.
The original post can be viewed Il post originale può essere visualizzato here qui .
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 Questo è il primo posto nella 30 Wordpress Hacks in 30 Days Series 30 Hacks Wordpress in 30 giorni Series !
If you use Wordpress - then this is a series you will want to bookmark right now! Se si utilizza Wordpress - quindi si tratta di una serie si vorranno segnalibro ora! You might even want to subscribe by email at the top of the page. Si potrebbe anche voler iscriversi tramite email nella parte superiore della pagina. 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. Se siete come me il tuo malato e stanco di googling il crap su web cercando di trovare semplici modi per incidere e Wordpress personalizzare il tuo blog o sito web. I’m going to give you a very useful and easy to perform Wordpress hack every day for a month! Io vado a darle una molto utile e facile da eseguire Wordpress hack ogni giorno per un mese! 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. Credo che sia più facile fare qualcosa come questo di scrivere un post Humongous con più informazioni di quanto non avrete mai leggere o riassunto in una sola seduta. Instead I’m going to give you one very simple and easy task to do each and every day. Invece ho intenzione di dare uno molto semplice e di facile compito di fare ogni giorno. Depending on your skill level, you may or may not want to take a look at last week’s post A seconda del tuo livello di competenze, si possono o non vogliono dare un'occhiata alla settimana scorsa post How to Create Your Own Wordpress Theme Come creare il tuo tema di Wordpress .
Wordpress Hack #1 - query_posts Wordpress Hack # 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. Oggi nella nostra prima Wordpress Hack nei nostri 30 giorni di "Hack-a-Thon" che andremo a conoscere la Wordpress "tag modello" query_posts. You can Potete read about query_posts in the Wordpress Codex here a leggere le informazioni query_posts nel Codex Wordpress qui . To use any of these examples you must place the PHP code snippet before “the loop”. Per utilizzare uno di questi esempi è necessario inserire il frammento di codice PHP prima di "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. Se non sai cosa "Loop" è, basta seguire il link nel paragrafo precedente per creare il tuo wordpress tema per una spiegazione. 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. Ogni frammento di codice in grado di utilizzare qualsiasi qualsiasi pagina che utilizza il "loop", come ad esempio il tuo index.php, category.php, archive.php, tag.php, o search.php.
Exclude posts that belong to a category Escludere che i post che appartengono a una categoria
Maybe you don’t want posts from a certain category showing up on your index or another archive page. Forse che non si vuole posti da una certa categoria visualizzati sul tuo indice o un altro archivio pagina. You could even use this to keep certain categories from showing in search results if you needed to. Si potrebbe anche utilizzare questo per mantenere determinate categorie di visualizzare nei risultati di ricerca se si deve. 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… Avete bisogno di conoscere la vostra categoria "ID" per farlo, basta recuperarla dalla tua bacheca sotto "Gestione-> Categorie", e il "-1" con il tuo ID # categoria come questa…
<?php query_posts('cat=-1'); ?> <? php query_posts ( 'cat =- 1');?> You can exclude multple categories like this… È possibile escludere multple categorie come questa…
<?php query_posts("cat=-1,-2,-3"); ?> <? php query_posts ( "cat =- 1, -2, -3");?> Retrieve a Post or Page Recuperare un post o 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)… Per recuperare un posto particolare è possibile chiamare da ID (elencati nella tua bacheca) oppure è piaciuto questo slug (utilizzare una riga di codice o l'altro, non entrambi)…
<?php query_posts('p=1'); //using post id query_posts('name=first-post'); //using post slug ?> <? php query_posts ( 'p = 1'); / / post utilizzando id query_posts ( 'name = primo post'); / / post con interlinea?> You can do the same thing to retrieve pages as well like this… È possibile fare la stessa cosa per recuperare le pagine e come questo…
<?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'); / / recupera pagina 7 solo query_posts ( 'circa pagename ='); / / recupera la pagina solo su?> When you use those examples it retrieves the entire post. Quando si utilizzano tali esempi che recupera l'intera posta. 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. Quando si è famoso per la scrittura di messaggi estremamente lungo (come io sono) è possibile solo per ottenere un parziale con il post "per saperne di più". This is especialy useful if you’re going ot feature certain posts on your index or other pages. Soprattutto quando questo è utile se si sta andando OT funzionalità di taluni posti sul tuo indice o di altre pagine. Here’s the code for that… Ecco il codice che…
<?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'); / / ricevere posta con ID di 5 $ più globale; più $ = 0; / / parziale viene posto con link per saperne di più?> You know that you can create pages, and you can also create “child pages” like I have on ths site. Voi sapete che è possibile creare pagine, e si può anche creare "bambino pagine" come ho a THS sito. I have a parent page called “series”, and then all the individual series index pages are children of that page. Ho una pagina padre chiamato "serie", quindi tutte le singole serie pagine indice sono figli di quella pagina. 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). Se vuoi avere un bambino pagina - che è anche possibile, ma non è possibile chiamare da id - dovete chiamare con un doppio interlinea come nell'esempio qui sotto (genitore slug barra bambino interlinea).
<?php query_posts('pagename=parent/child'); ?> <? php query_posts ( 'pagename = madre / bambino');?> Retrieve Post by Certain Authors Post recuperare da alcuni autori
If your blog has multiple authors you can retrive them by name or author id like this… Se il tuo blog è più autori è possibile retrive loro nome o l'autore id come questo…
<?php query_posts('author_name=John'); query_posts('author=3'); ?> <? php query_posts ( 'Giovanni author_name ='); query_posts ( 'autore = 3');?> Retrieve Every Single Post Recuperare ogni singolo post
Maybe you want to make some kind of an archive page or sitemap. Forse volete fare una sorta di un archivio o pagina mappa del sito. 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. O se non si crea una pagina con questa ricerca, naturalmente, dipende da quanti posti sono davvero, ma inserendo questo codice prima del ciclo, vengono elencati mai post avete tutti su una sola pagina. 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. Mentre il codice qui sotto mostra tutti i post su una sola pagina, si può cambiare il "-1" a solo 1 post, o 5, o 10, o comunque molti posti si desidera visualizzare.
<?php query_posts('posts_per_page=-1'); ?> <? php query_posts ( 'posts_per_page =- 1');?> Change the Order or Sequence of Posts Modificare l'ordine di sequenza o delle Poste
By default a Wordpress blog shows you posts in a journal fashion or reverse date order. Per impostazione predefinita un Wordpress blog mostra posti in una rivista di moda o invertire data ordine. You could choose to instead sort your posts by author or title like this. Si potrebbe invece scegliere di ordinare i posti di autore o di un titolo come questo. You could use either the author or title lines. Si può usare sia l'autore o il titolo.
<?php query_posts('orderby=author'); query_posts('orderby=title'); ?> <? php query_posts ( 'orderby = autore'); query_posts ( 'orderby = titolo');?> Using “orderby” there are many different parameters that you can use like these… Utilizzando "orderby" ci sono molti diversi parametri che è possibile utilizzare come questi…
* orderby=author * = Orderby autore
* orderby=date * = Orderby data
* orderby=category * = Orderby categoria
* orderby=title * = Orderby titolo
* orderby=modified * = Orderby modificati
* orderby=menu_order * Orderby = menu_order
* orderby=parent * = Orderby madre
* orderby=ID * Orderby = ID
* orderby=rand * Orderby = rand
Retrieve a Post by Time Period Recuperare un post di Periodo
There are many different ways to consruct a query to retrieve certain posts based by date only. Ci sono molti modi diversi di consruct una query per recuperare alcuni posti a base di data solo. Here’sa way to get them for a day of the month… Ecco un modo per loro per un giorno del mese…
<?php query_posts('day=15'); //all posts on the 15th ?> <? php query_posts ( 'giorno = 15'); / / tutti i post il 15?> You could also get them for the current month and year with a query like this… Si potrebbe anche far loro per il mese in corso e l'anno con una query come questa…
<?php $current_month = date('m'); ?> <?php $current_year = date('Y'); ?> <?php query_posts("cat=22&year=$current_year&monthnum=$current_month&order=ASC"); ?> <? php $ data = current_month ( 'm');?> <? php $ data = current_year ( 'Y');?> <? php query_posts ( "cat = 22 & anno = $ current_year & monthnum = $ current_month & ordine = ASC"); ?> Retrieve Posts based on Tags Posti recuperare basata su tag
You can retrieve posts for a specific tag or tags like this (use one line of code at a time only). Si possono recuperare i posti per un determinato tag o tag di questo tipo (utilizzare una riga di codice in un momento solo). 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. La prima linea recupera posti, con una particolare etichetta, la seconda linea è il formato per ottenere posti per più tag, ma la terza linea è per avere un post che sono stati contrassegnati in più categorie. In other words the second line will retrieve all posts tagged as bread all posts tagged as baking. In altre parole la seconda linea di recuperare tutti i messaggi contrassegnati come il pane tutti i post contrassegnati come cottura. But the third line will get only posts tagged in bread and baking and recipe. Ma la terza linea otterrete solo posti contrassegnati nel pane e cottura e la ricetta.
<?php query_posts('tag=cooking'); query_posts('tag=bread,baking'); query_posts('tag=bread+baking+recipe'); ?> <? php query_posts ( 'tag = cucina'); query_posts ( 'tag = pane, cottura'); query_posts ( 'tag = pane cottura + + ricetta');?> I hope this helps you do a little Wordpress “theme hacking” and customize your blog. Spero che questo ti aiuta a fare un po 'di Wordpress "tema" hacking "e personalizzare il tuo blog. If you have any questions about query_posts please comment now, and we’ll see your tomorrow for the next hack! Se avete qualunque domande circa query_posts commentare adesso, e vedremo il tuo domani, per il prossimo hack!
Tags: Tag: blog-help blog-aiuto , tutorial , wordpress-hacks WordPress-hack























April 15th, 2008 at 12:08 am 15 aprile 2008, 12:08 am
I had actually been looking for the one about authors. Avevo effettivamente alla ricerca di un sugli autori.
thanks a lot, it been a big help. Thanks a lot, è stato di grande aiuto.
Mark Wilson’s last blog post.. Mark Wilson ultimo post sul blog .. I hate the word “niche” Odio la parola "di nicchia"
April 15th, 2008 at 9:04 am 15 aprile 2008, 9:04 am
Loving the idea even though this one is sort of irrelevant for me, cannot wait for the rest. Amare l'idea, anche se questo è uno sorta di irrilevante per me, non possono attendere per il resto.
April 28th, 2008 at 10:41 pm 28 aprile 2008, 10:41 pm
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! Okay… in wordpress newbie (ma qualcuno che ha scelto di immersione testa-in primo WP sviluppo… mi sciocca) non posso dirvi quanto apprezzo questa serie che si sta 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! Una volta ho finalmente mio blog installato e funzionante, ho intenzione di avere a lancia un ringraziamento per l'aiuto che mi ha così tanto!
April 29th, 2008 at 7:59 am 29 aprile 2008, 7:59 am
@Erika - glad to help! @ Erika - lieti di aiutarvi! I love comments like this, because it means I made the right decision in starting this series… Amo commenti come questo, perché significa che ho fatto la scelta giusta in questa serie a partire…