Plugin: Posts in category 1.1
This is my very first Wordpress plugin
The plugin shows a customizable list of links to the posts published in the specified categories (also multiple ones).
You can show posts from one or more specific categories, by passing an array of their IDs as a function value, or show other posts from the categories under which the currently active post is published (as I do in my sidebar!).
You can see the plugin code here. If you copy this code and paste it into a .php file, you’ll have the plugin ready to rock!
The features list include:
- Show posts published under one or more categories (also the current post’s one if you wish).
- Limit the number of shown posts.
- Customize the order in which post links will be shown.
- Exclude posts (from v.1.1)
Using this plugin is simple: install and activate it easily as usual, then call the function, inside The Loop, with this syntax:
Let’s explain briefly these arguments:
- categories-array is an array containing the IDs of the category of which you want to display posts;
- post-limit is the number of the posts link you want to show;
- order-by is the criteria for which you want to order posts by (that is no other from your POSTS table field names, comma separated);
- exclude contains IDs of the post to exclude. Can be a numeric string, array or empty.
You will find extended documentation and usage examples directly into the plugin source code.
This plugin is released under GPL license.
Special thanks goes to:
Mrbrown, that gave me the initial input for plugin development (in this forum topic), and the whole Wordpress italian community that made this possible.



















Zelig wrote:
Plugin molto interessante, da tempo cercavo qualcosa del genere! Pensavo di utilizzarlo nella pagina di visualizzazione dei singoli post (single.php) e mi chiedevo se per caso conosci un modo per modificare la query in modo da escludere dall’elenco l’articolo correntemente visualizzato. Grazie!
13 May, 2006 @ 8:57 am
root@geek-notes.com wrote:
Grazie del suggerimento, Zelig.
Ho modificato il plugin in modo da poter escludere il post corrente (basta passare $post->ID come quarto argomento) e ho fatto qualche altra piccola modifica alla funzione (che ora va stampata dal template e non stampa lei direttamente… vedi i commenti alla funzione e il changelog).
Ciao!
14 May, 2006 @ 4:57 pm
Zelig wrote:
Grande!
14 May, 2006 @ 6:42 pm
Mateus Neves wrote:
This plugin is very nice… Tanks!
15 May, 2006 @ 1:04 am
Iva wrote:
Grazie mille per questo plugin! Usavo uno che era simile, ma non lavorava con Word Press 2.0. Questo mi aiuterà molto, con organizzare le categorie sul sito che è troppo grande:)
1 June, 2006 @ 4:07 am
pietro wrote:
non potresti inserire degli esempi pratici di come si usa, non tutti siamo programmatori, io ad esempio non ho capito se va inserito all’interno del template e dove, e quali parametri passare
23 August, 2006 @ 6:03 pm
KJ wrote:
Will this work with the latest version of wordpress?
Thanks
14 January, 2007 @ 12:11 am
KJ wrote:
Also would it be possible to show the Title, Date and excerpt for each posts? Would those just be included in the query in the source code?
14 January, 2007 @ 12:13 am
Alessandro wrote:
ciao maurizio
questo plugin sembra veramente ottimo e mi sarebbe utilissimo. ho visto la documentazione e anche il materiale di partenza su WP-it ma non riesco a farlo funzionare. sono alle prime armi ma imparo in fretta. puoi mandarmi qualche esempio?
grazie, a presto,
alessandro
14 April, 2007 @ 2:46 pm
LolitochkaBC wrote:
Ð?аану-ка ребÑ?трки олÑ?уем!!!
ПризнавайетÑ?ÑŒ проказники и владлеьцы Ñ?йата www.geek-notes.com ))))
ЧТО вы будеате делать Ñ?тим летом!?
10 May, 2007 @ 10:30 am
Rafa wrote:
Dear Mauricio, I have copied the text of http://www.geek-notes.com/files/wp_plugin_posts_in_category.htm and saved it as post_in_category.php. I’ve uploaded it within a folder in plugins, activate the plugin and so far everything went well. But, now I’ve copied the code
cat_ID);
} ?>
Last posts from the same categories of this post
ID);?>
into a post, and further I’ve copied and pasted the code
echo mp_posts_in_cat(’categories-array’,'post-limit’,'order-by’, ‘exclude’)
into my “single post” theme inside the “loop”, but that has completley messed up my word press and made mysql to get stuck.
could you please be a little more clear about how exactley all this has to be done. I’m not used to php at all, so in the user instructions you should state the exact postion and format where all the code has to be put for this to work.
Thanks from a “not-at-all-geek”
Rafael
15 June, 2007 @ 11:34 am
Rossi Alex wrote:
Simply perfect for all SEO.
Good job.
25 August, 2007 @ 9:43 am
Dario wrote:
Bellissimo, “pareva” funzionarmi, ma mi ha dato una fila di errori quando ho fatto il logout da wordpress (vers.2.2.1), e anche quando provo a fare login!!!
Copio di seguito:
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-login.php on line 12
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-includes/pluggable.php on line 381
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-includes/pluggable.php on line 382
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-includes/pluggable.php on line 383
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-includes/pluggable.php on line 384
Warning: Cannot modify header information - headers already sent by (output started at /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-content/plugins/ArticoliCategoria.php:2) in /home/mhd-01/www.giorgionecalcio.it/htdocs/wp-includes/pluggable.php on line 331
Qualche suggerimento??
ciao!
8 September, 2007 @ 4:14 pm
Stefano wrote:
Ciao Maurizio,
ho rilasciato la versione 1.2 del tuo plugin compatibile con WP 2.3.x. Ecco il link: http://www.astronomia.com/temp/posts-in-category.zip
A presto!
4 November, 2007 @ 8:52 pm
Izzyweb.it wrote:
Ottimo plugin lo installo subito
Grazie
21 November, 2007 @ 4:51 pm
naisioxerloro wrote:
Hi.
Good design, who make it?
28 November, 2007 @ 4:44 pm
Silvana wrote:
grazie Maurizio per il plugin, provo lo stesso a farti la domanda anche se mi sembra non ti piaccia rispondere..chissà magari per una valtellinese..
nella lista “concorsi” che mi crea, non riesco a capire perchè alla fine, mi aggiunge un link ad una pagina del sito?? ho guardato o riguardato il codice ma mi sfugge qualcosa?
grazie
17 April, 2008 @ 11:39 pm
Dominic Desbiens wrote:
It work on Wordpress 2.5 with modification by Stefano, thanks. But is there an optimisation or changes required for Wordpress 2.5 ??
Es trabajar en Wordpress con 2,5 modificación de Stefano, gracias. Pero hay una optimización o los cambios necesarios para Wordpress 2,5? Responder en Inglés, por favor.
30 May, 2008 @ 6:38 pm