Este é um post de José Lopes.
Ao configurar um site com o Wordpress criei uma entrada author.php sobre os autores presentes no site, como se encontra definido em Author Templates, por modo a ter uma descrição sobre cada autor e uma lista dos artigos (posts) escritos no site.
Este Plugin possibilita apresentar uma lista completa de artigos do autor, incluíndo os artigos em que o autor foi co-autor.
Posted by José Lopes.
While setting my site with Wordpress I created an author.php to display information about the
authors of the site, much as it is defined in Author Templates. I wanted to have
a description about the author itself and a list of posts writen by him.
This plugin displays the complete post list of one Author, with the total number, including the co-author participations.
O que me levou a fazer este Plugin foi uma série de problemas, que irei detalhar de seguida, e o facto de não ter encontrado nada já feito para os resolver.
Os problemas que me deparei residiam na lista de artigos do autor:
- Ao ter definido um número máximo de artigos a serem apresentados por página não conseguia mostrar todos os artigos do autor, quando a sua quantidade ultrapassava esse número máximo.
- Se o autor fosse co-autor de outros artigos a sua quantidade não era contabilizada nem esses artigos eram listados.
Download
Pode fazer o download de um dos ficheiros: author-complete-post-list.zip ou author-complete-post-list.tar.gz
Instalação
- Descomprimir o ficheiro para o directório wp-content/plugins
- Será criada a directoria author-complete-post-list aquando da descompressão, caso contrário criar manualmente e colocar os ficheiros do Plugin dentro dela.
- Activar o Plugin Author Complete Post List através do painel administrativo.
- O Plugin fica assim disponível para utilização.
Modo de Utilização
Este foi criado com o objectivo de ser aplicado em author.php mencionado atrás, pelo que o exemplo do modo de utilização vai ser neste âmbito.
Assim com base no exemplo do Wordpress para este php, basta as duas linhas de código seguintes para obter a lista de artigos do autor.
<?php total_posts($author, $curauth->user_login, 'pt_PT') ; ?>
<?php full_post_list($author, $curauth->user_login, 'pt_PT') ; ?>
Descrevendo o código:
- A primeira linha devolve o texto introdutório para a lista de artigos, com o total de artigos.
- A segunda linha devolve a lista de todos os artigos do autor, incluído aqueles que é co-autor, ordenada pelo mais recente.
- Quanto aos argumentos das funções:
- O primeiro é definido pelo Wordpress e representa o autor para a página em visionamento.
- O segundo é definido no início do ficheiro author.php do exemplo do Wordpress,
sendo seleccionado o login do autor do posto com o tag user_login.
- O terceiro é opcional, ele define qual a linguagem do output. Aceita 'pt_PT' para o português e 'en_GB' para o inglês.
Em caso de omissão é assumido o default que é o português.
Exemplo de output:
Este(a) autor(a) tem 3 artigo(s) neste site:
- Artigo 3 a 06/07/2007, arquivado em Sem Categoria
- Artigo 2 a 06/07/2007, arquivado em Sem Categoria
- Artigo 1 a 05/07/2007, arquivado em Sem Categoria
Notas finais
Este Plugin foi testado para a versão 2.2 do Wordpress, pelo que qualquer informação sobre a sua utilização em outras versões será bem vinda.
Não existem requesitos especiais para a intalação ou utilização deste Plugin, no entanto, uma vez que uma das coisas que se pretende é incluir os artigos de co-autoria será bom fazer atenção a como se regista o co-autor. Assim concluo esta exposição com os seguintes pontos:
- Para inserir um co-autor (ou mais) num artigo, utilizo o Plugin multiple-authors que permite incluir no Campo Personalizado uma chave de nome other_author cujo valor deve ser o nome de login do co-autor (uma chave por cada co-autor).
- O uso do Plugin multiple-authors permite incluir facilmente no artigo os nomes dos vários autores ou de um só se for o caso, assim como registar automaticamente um co-autor se o utilizador tiver o papel de Editor. Tem as suas vantagens e desvantagens pois ao adicionar automaticamente autores pode adicionar um que por engano editou e gravou o artigo, embora se possa posteriormente anular essa acção apagando a respectiva entrada no Campo Personalizado do artigo.
- Caso não utilize este Plugin, pode adicionar a chave manualmente desde que mantenha o nome other_author que o nosso Plugin funcionará. É importante que a chave tenha o nome other_author.
- Tem ainda de fazer atenção que o valor da chave tem de ser o nome de login do autor, caso contrário ele não será reconhecido.
- A internacionalização do Plugin não está feita nesta fase e ficará para uma ocasião futura. Contudo, a opção entre as duas línguas já cobre a maioria das necessidades.
I was having some problems setting up the authors properly so, since I didn't any thing to solve it, I created this Plugin.
The problems appeared while displaying the list of posts of the author:
- Having set the maximum number of posts to be displayed by page it was not possible to display all the author posts, if the
total posts exceeded that number.
- If the author was also co-author of other posts, theses one were not listed neither taken into account for the posts total number.
Download
You can download one of the files that serves you better:
author-complete-post-list.zip or
author-complete-post-list.tar.gz
Installation
- Descompress the file to the directory wp-content/plugins
- The directory author-complete-post-list will be created, but if not do it manually and place the Plugin files inside.
- Activate the Plugin Author Complete Post List on the administration pannel.
- You are ready to rock!
How to use it
As I said previously the Plugin was created to be used in author.php so the next example is based in this assumption.
Taking the Wordpress php
example, two code lines are enough to get the
author's post list.
<?php total_posts($author, $curauth->user_login, 'pt_PT') ; ?>
<?php full_post_list($author, $curauth->user_login, 'pt_PT') ; ?>
Explaining the code:
- The first line returns the introduction text for the post list, with the total of posts.
- The second line returns the author's post lists, including the ones in which he is co-author, sorted by the most recent post.
- Checking the function args:
- The first is defined by Wordpress and identifies the author.
- The second is defined at the top of the author.php file of Wordpress,
selecting the author login with the tag user_login.
- The third is optional, defining the output language. It accepts 'pt_PT' for portuguese and 'en_GB' for english.
By default it is set for portuguese.
Output example:
This author has 3 post(s):
- Post 3 in 06/07/2007, stored at Nowhere
- Post 2 in 06/07/2007, stored at Nowhere
- Post 1 in 05/07/2007, stored at Nowhere
Final notes
This Plugin was tested with Wordpress v.2.2, so any info about other version is welcome.
There are no special requirements to install or use this Plugin, nevertheless, since one of the major goals is to include the
co-author posts it would be wise to make attention at how you define the co-author thing. In this way I end this presentation
with the following points:
- To insert one or more co-authors in a post you can use the Plugin
multiple-authors that allows to set on Personalized Field
the key word other_author, whose value should be the co-author login name (one key for co-author).
- The use of the Plugin multiple-authors allows to
easily include several author names in the post and to automatically record the co-author if the user edits the post.
It has advantages and disadvantages because recording automatically the co-author it may include the author by mistake.
- If you don't use the Plugin, you can always use the other_author key word to manually add the author name
and my Plugin will work. It is important to keep the name other_author as the key word.
- You have to certain to place the author login name in the key word value, otherwise it will not be recognized.
- The Plugin internationalization is not yet done but it may be done in the future. However, the two language option included in
the Plugin should cover most of the needs.
Thanks