<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mas que Wordpress - Tutoriales, recursos web, JQuery y PHP, Wordpress , twitter y muchos recursos más &#187; template</title>
	<atom:link href="http://www.masquewordpress.com/tag/template/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.masquewordpress.com</link>
	<description>Tutoriales y recursos web sobre JQuery , PHP, Wordpress , twitter. Aprende diseño web y programación</description>
	<lastBuildDate>Fri, 03 Feb 2012 19:33:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Como añadir Google custom search a WordPress y modificar el template page</title>
		<link>http://www.masquewordpress.com/como-anadir-google-custom-search-a-wordpress-y-modificar-el-template-page/</link>
		<comments>http://www.masquewordpress.com/como-anadir-google-custom-search-a-wordpress-y-modificar-el-template-page/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 02:29:02 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[adsense]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[tips de wordpress]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=330</guid>
		<description><![CDATA[En este tutorial les voy a explicar una de las formas para agregar google custom search a wordpress. Como saben los que me siguen hace tiempo, no siempre me gusta usar plugins ya que el template de mi wordpress esta modificado y no siempre funcionan a la perfección. Lo primero que necesitamos es ir a [...]]]></description>
			<content:encoded><![CDATA[<p>En este tutorial les voy a explicar una de las formas para agregar <strong>google custom search</strong> a wordpress. Como saben los que me siguen hace tiempo, no siempre me gusta usar <a href="http://wordpress.org/extend/plugins/google-custom-search-for-wordpress/">plugins</a> ya que el template de mi wordpress esta modificado y no siempre funcionan a la perfección.</p>
<p>Lo primero que necesitamos es ir a la <a href="https://www.google.com/adsense/">página de Adsense</a> y <a href="https://www.google.com/adsense/afs-settings">crear un motor de búsqueda personalizado</a>.</p>
<p>Ingresas los datos que pide el formulario:</p>
<ol>
<li>En <strong>&#8220;¿Qué quiere buscar?</strong><strong>&#8220;</strong> seleccionamos <em><strong>Sólo los sitios que seleccione</strong></em>.</li>
<li>En <strong>&#8220;Seleccione algunos sitios</strong><strong>&#8220;</strong> debemos ingresar la URL del blog donde se va a realizar la búsqueda.</li>
<li>En <strong>&#8220;Seleccione una edición</strong><strong>&#8220;</strong> seleccionamos <em> <strong>Edición estándar.</strong></em></li>
<li>En <strong>&#8220;Palabras clave&#8221; </strong>podes poner algunos keywords que describar tu blog.</li>
<li>Despues elegimos el <strong>lenguaje </strong>de tu blog.</li>
<li>El <strong>formato o estilo</strong> de  la caja de texto. ( Más adelante voy a explicar como cambiar el estilo)</li>
<li>Y donde abrir los resultados. En este caso elegimos <strong>nuestro propio sitio</strong> y ponemos una dirección del estilo &#8220;http://masquewordpress.com/<strong>buscar</strong>&#8220;.</li>
<li>Elegimos solo <strong>mostrar anuncios</strong> en la parte derecha(esto a gusto de cada uno).</li>
<li>Cambiamos <strong>el estilo </strong>con la paleta de colores.</li>
<li><strong>Aceptamos </strong>las <a href="http://www.google.com.ar/coop/docs/cse/tos.html" target="_blank">Condiciones de servicio</a>.</li>
<li><strong>Elegimos un nombre</strong> para el buscador y le damos a obtener el código.</li>
</ol>
<p><span id="more-330"></span></p>
<p>Una ves terminados estos pasos vamos a obtener 2 códigos:</p>
<p><strong>La caja de texto del buscador</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://masquewordpress.com/buscar/&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cse-search-box&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cx&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;partner-pub-xxxxxxxxx:xxxxxx&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cof&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;FORID:x&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;31&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sa&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Buscar&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com.ar/coop/cse/brand?form=cse-search-box&amp;amp;lang=es&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p><strong>Y los resultados del buscador</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cse-search-results&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var googleSearchIframeName = &quot;cse-search-results&quot;;
var googleSearchFormName = &quot;cse-search-box&quot;;
var googleSearchFrameWidth = 800;
var googleSearchDomain = &quot;www.google.com.ar&quot;;
var googleSearchPath = &quot;/cse&quot;;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com/afsonline/show_afs_search.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<h2>Creando la página /buscar/ para que muestre lo resultados.</h2>
<p>Para crear la página que nos muestre los resultados tan solo debemos ir en nuestro WordPress a <strong>Pages &#8211;&gt; Add New</strong> e ingresar en el nombre de la página &#8220;<strong>Buscar</strong>&#8221; asegurandonos que el <strong>Permalink <strong>sea</strong>:</strong><strong> <span id="sample-permalink">http://masquewordpress.com/<span id="editable-post-name" title="Click to edit this part of the permalink">buscar</span>/ .</span></strong></p>
<h2><strong><span>Como modificar el template page de wordpress para darle el estilo necesario a la página de busquedas<br />
</span></strong></h2>
<div class="iconbox"><span class="iconbox_icon"><img src='http://www.masquewordpress.com/wp-content/themes/brightbox/images/icons/iconbox/alert.png' alt='' /></span><div class="iconbox_content"><h3 class="iconbox_content_title">Actualización</h3><p>Les voy a explicar como hacerlo hoy en día de una forma más ordenada.</p>
</div></div>
<p>Hoy en día existen diferentes formas de modificar el template. Una forma de llamar a un template para una página en concreto puede ser:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">page<span style="color: #339933;">-</span>buscar<span style="color: #339933;">.</span>php</pre></td></tr></table></div>

<p>Y dentro de page-buscar.php ponemos el código personalizado. En este caso podemos por ejemplo copiar el contenido de page.php y reemplazar la parte del content con lo que google nos dio. De esta forma queda ordenado en nuestro archivos.</p>
<p>También se puede usar la función <a href="http://codex.wordpress.org/Function_Reference/get_template_part" rel="nofollow">get_template_part();</a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">get_template_part<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mipagina-de-buscar'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>O  también podemos crear un template con</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
&nbsp;
Template Name: Página para buscar
&nbsp;
*/</span></pre></td></tr></table></div>

<p>y luego seleccionar el template desde el menu de templates en nuestra página.</p>
<p>&nbsp;</p>
<p>&#8212;&#8212;- Ahora el método antiguo del post&#8212;&#8212;-<br />
<span>Aunque ya tenemos la página /buscar/ creada , necesitamos hacer que muestre los resultados y para ello necesitamos ingresar el código obtenido en el primer paso</span><span>.</span><strong></strong></p>
<p><span>A su ves</span><span> ,al mostrar publicidad del lado derecho el tamaño mínimo del DIV </span><strong>cse-search-results </strong>será de 850px , por lo que no entraría en el blog si no quitamos el sidebar derecho. Como podemos hacer esto? De una manera fácil modificando en nuestro template <strong>page.php</strong> gracias a la función <a href="http://codex.wordpress.org/Function_Reference/is_page">is_page()</a>.</p>
<p>Dicha página puede ser encontrada en nombredetublog/wp-content/themes/nombredetutheme/page.php</p>
<p><strong>Page.php</strong> es el template que se encarga de montar la estructura por defecto de una página. Suele cargar las diferentes partes de la página llamando diferentes funciones:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php get_header<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> //Obtenemos el header
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;?php</span>
&nbsp;
<span style="color: #009900;">&lt;!-- begin post --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&lt;?php the_permalink(); ?&gt;</span></span>&quot;&gt;<span style="color: #009900;">&lt;?php the_title<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span> // El título del post
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
Posted on <span style="color: #009900;">&lt;?php the_time<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'F j, Y'</span><span style="color: #66cc66;">&#41;</span> ?&gt;</span> by <span style="color: #009900;">&lt;?php the_author_posts_link<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> //Escrito en....
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
<span style="color: #009900;">&lt;?php the_content<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> //El post en si
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;?php the_tags<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Tags: '</span>, <span style="color: #ff0000;">', '</span>, <span style="color: #ff0000;">''</span><span style="color: #66cc66;">&#41;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> //Tags
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Filed Under: <span style="color: #009900;">&lt;?php the_category<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">', '</span><span style="color: #66cc66;">&#41;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span> //Categoria
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- end post --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;comments&quot;</span>&gt;&lt;?php comments_template<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span> //Carga los comentarios
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- END content --&gt;</span>
<span style="color: #009900;">&lt;?php get_sidebar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; get_footer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> // Por ultimos el sidebar y el footer</pre></td></tr></table></div>

<p>En mi caso en concreto necesitaba alterar la página de busquedas por lo que agregue el siguiente código al principio una ves cargado el header ( ya que si quiero la cabezera de la web).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;?php get_header<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> //Obtenemos el header
&nbsp;
<span style="color: #009900;">&lt;?php if <span style="color: #66cc66;">&#40;</span> is_page<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'Buscar'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> ?&gt;</span>  // COMPRUEBO SI LA PÁGINA ES &quot;Buscar&quot;
<span style="color: #808080; font-style: italic;">&lt;!-- Google CSE Search Box Begins  --&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;busqueda-wrapper&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;form-busqueda&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>Busca que con suerte encontras<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h2</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://masquewordpress.com/buscar/&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cse-search-box&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cx&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;partner-pub-XXXXXX:XXXXXX&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cof&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;FORID:X&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;hidden&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;q&quot;</span> <span style="color: #000066;">size</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;31&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;submit&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;sa&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Buscar&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;google-boton&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;border:none;&quot;</span><span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">form</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com.ar/coop/cse/brand?form=cse-search-box&amp;amp;lang=es&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- Google CSE Search Box Ends --&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!-- Google Search Result Snippet Begins --&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cse-search-results&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
var googleSearchIframeName = &quot;cse-search-results&quot;;
var googleSearchFormName = &quot;cse-search-box&quot;;
var googleSearchFrameWidth = 800;
var googleSearchDomain = &quot;www.google.com.ar&quot;;
var googleSearchPath = &quot;/cse&quot;;
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com/afsonline/show_afs_search.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!-- Google Search Result Snippet Ends --&gt;</span>
<span style="color: #009900;">&lt;?php  get_footer<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; ?&gt;</span> //INCLUYO EL FOOTER Y DOY POR TERMINADA LA PÁGINA
&nbsp;
<span style="color: #009900;">&lt;?php  <span style="color: #66cc66;">&#125;</span>else<span style="color: #66cc66;">&#123;</span> ?&gt;</span> // EN CASO  DE QUE SEA OTRA PÁGINA CARGO EL TEMPLATE CON NORMALIDAD
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;content&quot;</span>&gt;</span>
......
&nbsp;
......
......
&nbsp;
......
&nbsp;
<span style="color: #009900;">&lt;?php</span></pre></td></tr></table></div>

<p>Como es normal, pueden agregar lo que quieran de código HTML y luego usar la <strong>hoja de estilo CSS</strong> del template que esten usando para darle forma.</p>
<h2>Como añadir google custom search en el sidebar o barra lateral.</h2>
<p>Al igual que page.php, <strong>sidebar.php</strong> se encuentra en nombredetublog/wp-content/themes/nombredetutheme/sidebar.php y para añadir el formulario de google custom search tan solo tenemos que buscar el formulario de busqueda actual que tenemos y cambiarlo por el código que nos dio google.</p>
<p>Igual que antes podemos agregar el código HTML necesario y luego darle forma con CSS.</p>
<h2>Como sacar o cambiar la marca de agua de google, y como cambiar el estilo del text box de google custom search</h2>
<p>En la <strong>parte final</strong> del código del formulario de busqueda aparece un archivo javascript que va a ser el encargado de aplicar el estilo y la marca de agua a el texto box.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.google.com.ar/coop/cse/brand?form=cse-search-box&amp;amp;lang=es&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></td></tr></table></div>

<p>Lo que hay que hacer es pegar el link  en <a href="http://www.getfirefox.com">firefox </a>y descargarse el archivo .js para moder modificarlo.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cse-search-box'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> f <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'searchbox_demo'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f <span style="color: #339933;">&amp;&amp;</span> f.<span style="color: #660066;">q</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #003366; font-weight: bold;">var</span> q <span style="color: #339933;">=</span> f.<span style="color: #660066;">q</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> n <span style="color: #339933;">=</span> navigator<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> l <span style="color: #339933;">=</span> location<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n.<span style="color: #660066;">platform</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Win32'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> q.<span style="color: #660066;">style</span>.<span style="color: #660066;">cssText</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'border: 1px solid #7e9db9; padding: 2px;'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>q.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> q.<span style="color: #660066;">style</span>.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#FFFFFF url(http:<span style="color: #000099; font-weight: bold;">\x</span>2F<span style="color: #000099; font-weight: bold;">\x</span>2Fwww.google.com.ar<span style="color: #000099; font-weight: bold;">\x</span>2Fcoop<span style="color: #000099; font-weight: bold;">\x</span>2Fintl<span style="color: #000099; font-weight: bold;">\x</span>2Fen<span style="color: #000099; font-weight: bold;">\x</span>2Fimages<span style="color: #000099; font-weight: bold;">\x</span>2Fgoogle_custom_search_watermark.gif) left no-repeat'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> f <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> q.<span style="color: #660066;">style</span>.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#ffffff'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> q.<span style="color: #000066;">onfocus</span> <span style="color: #339933;">=</span> f<span style="color: #339933;">;</span> q.<span style="color: #000066;">onblur</span> <span style="color: #339933;">=</span> b<span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!/</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">&amp;?</span><span style="color: #009900;">&#93;</span>q<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #339933;">^&amp;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">/</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span>l.<span style="color: #660066;">search</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> b<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Como pueden ver lo separe un poco para que sea más facil explicarlo. En mi caso , al tener una imagen de fondo para el cuadro de busquedas tan solo elimine la linea que le aplicaba los  bordes</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>n.<span style="color: #660066;">platform</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'Win32'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> q.<span style="color: #660066;">style</span>.<span style="color: #660066;">cssText</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'border: 1px solid #7e9db9; padding: 2px;'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Y despues la que aplicaba la marca de agua :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> b <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>q.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> q.<span style="color: #660066;">style</span>.<span style="color: #660066;">background</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#FFFFFF url(http:<span style="color: #000099; font-weight: bold;">\x</span>2F<span style="color: #000099; font-weight: bold;">\x</span>2Fwww.google.com.ar<span style="color: #000099; font-weight: bold;">\x</span>2Fcoop<span style="color: #000099; font-weight: bold;">\x</span>2Fintl<span style="color: #000099; font-weight: bold;">\x</span>2Fen<span style="color: #000099; font-weight: bold;">\x</span>2Fimages<span style="color: #000099; font-weight: bold;">\x</span>2Fgoogle_custom_search_watermark.gif) left no-repeat'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Tampoco tienen porque eliminarlas, si quieren pueden cambiar el estilo o aplicar su propia marca de agua. Un vez terminado , graban el archivo .js, lo suben al servidor y modifican el formulario con la dirección del archivo modificado.</p>
<p>Con eso ya tendrian su propio buscador google dentro de wordpress con publicidad adsense incluida. Espero que les sirva de ayuda. Un saludo</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/como-anadir-google-custom-search-a-wordpress-y-modificar-el-template-page/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Como mostrar posts de forma aleatoria en el sidebar de wordpress</title>
		<link>http://www.masquewordpress.com/como-mostrar-posts-de-forma-aleatoria-en-el-sidebar-de-wordpress/</link>
		<comments>http://www.masquewordpress.com/como-mostrar-posts-de-forma-aleatoria-en-el-sidebar-de-wordpress/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 02:22:43 +0000</pubDate>
		<dc:creator>Damian</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://masquewordpress.com/?p=261</guid>
		<description><![CDATA[Hoy estuve mirando como hacer para mostrar algunos posts de forma aleatoria en el sidebar derecho de mi blog. Esto además de servir para que mis lectores vean una selección de posts al azar ,y así descubrir alguno que les sea de interes, es de utilidad para que los buscadores indexen más cantidad de páginas [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy estuve mirando como hacer para mostrar algunos posts de forma aleatoria en el sidebar derecho de mi blog. Esto además de servir para que mis lectores vean una selección de posts al azar ,y así descubrir alguno que les sea de interes, es de utilidad para que los buscadores indexen más cantidad de páginas y así aumentar la posibilidad de que indexen todo el sitio.<br />
Aunque existen infinidad de <a href="http://wordpress.org/extend/plugins/">Plugins</a> que crean widgets para realizar esta función, yo buscaba algo más simple y que pudiera agregar yo a mi template. Si algo he descubierto últimamente es que los widgets no se llevan bien con los templates modificados.<br />
Despues de navegar por unos minutos di con un <a href="http://codex.wordpress.org/Template_Tags/">template tag</a> (Se utilizan para mostrar información dinámica y así poder crear o modificar templates de una forma facil).</p>
<p>La template tag es cuestión es :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">&lt;?php</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'arguments'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Donde la función get_posts se encarga de devolver cierta cantidad de posts dependiendo de los argumentos que le pasemos. Veamos algunos ejemplos:</p>
<h2>1.Últimos Posts ordenados alfabeticamente por título.</h2>
<p>El siguiente código muestra los últimos 10 posts ordenados alfabeticamente de forma ascendente. De ellos mostrará la fecha, el título y el extracto del artículo.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
 <span style="color: #000088;">$postslist</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=10&amp;order=ASC&amp;orderby=title'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$postslist</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 
    setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #000000; font-weight: bold;">?&gt;</span> 
 &lt;div&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_date<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
 &lt;br /&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>   
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
 &lt;/div&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<h2>1.Mostrar Posts de forma aleatoria.</h2>
<p>El siguiente código mostrará  5 posts elegidos al azar por la función MySQL RAND() en el atributo orderby. Esta es la función que utilizo yo en mi barra lateral derecha para mostrar últimos artículos.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&lt;h2&gt;Últimos artículos&lt;/h2&gt;
    &lt;ul&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span>
 <span style="color: #000088;">$rand_posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'numberposts=6&amp;orderby=rand'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rand_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
 <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;/ul&gt;</pre></td></tr></table></div>

<p>Como pueden ver es muy fácil obtener los posts con diferentes opciones. Para ver un listado completo de opciones consulten la página de <a href="http://codex.wordpress.org/Template_Tags/get_posts#Parameters:_WordPress_2.6.2B">codex wordpress</a>. Un saludo y hasta otra.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.masquewordpress.com/como-mostrar-posts-de-forma-aleatoria-en-el-sidebar-de-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

