<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Commenti a: Very short trick: WordPress, escludere pagine e post dalla ricerca</title>
	<atom:link href="http://www.undolog.com/2009/07/08/very-short-trick-wordpress-escludere-pagine-e-post-dalla-ricerca/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.undolog.com/2009/07/08/very-short-trick-wordpress-escludere-pagine-e-post-dalla-ricerca/</link>
	<description>Research &#38; Development  Blog</description>
	<lastBuildDate>Thu, 09 Feb 2012 11:24:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>Di: Giovambattista Fazioli</title>
		<link>http://www.undolog.com/2009/07/08/very-short-trick-wordpress-escludere-pagine-e-post-dalla-ricerca/#comment-5502</link>
		<dc:creator>Giovambattista Fazioli</dc:creator>
		<pubDate>Mon, 10 Oct 2011 10:40:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2146#comment-5502</guid>
		<description>&lt;b&gt;@matteo:&lt;/b&gt;: per cercare solo nel titolo, che ne sappia io, si può agire sulle condizioni di where generate durante la ricerca. Se provi ad inserire nel file [cci]functions.php[/cci] il seguente codice:
[cc_php]
function exclude_post_content($where) {
  if (is_search()) {
    $pattern = &#039;/OR\s*\(\w+\.post_content\s+LIKE\s*(\&#039;[^\&#039;]+\&#039;)\s*\)/&#039;;
    $where = preg_replace( $pattern, &quot;&quot;, $where);
}
return $where;
}
add_filter(&#039;posts_where&#039;, &#039;exclude_post_content&#039;);
[/cc_php]

In pratica elimini la codizione di ricerca del contenuto dalla select che esegue normalmente Wordpress. 

Per le &#039;tag&#039; la questione è simile agli esempi che si trovano nell&#039;artiolo, cioè userie il filtero [cci]pre_get_posts[/cci]. Ad esempio, se vuoi cercare solo negli articoli con tag &#039;prima-tag&#039;, usa:

[cc_php]
function search_filter($query) {
  if ($query-&gt;is_search) {
    $query-&gt;set(&#039;tag&#039;, &#039;prima-tag&#039;);
  }
  return $query;
}
add_filter(&#039;pre_get_posts&#039;,&#039;search_filter&#039;);
[/cc_php]</description>
		<content:encoded><![CDATA[<p><b>@matteo:</b>: per cercare solo nel titolo, che ne sappia io, si può agire sulle condizioni di where generate durante la ricerca. Se provi ad inserire nel file <code class="codecolorer text default"><span class="text">functions.php</span></code> il seguente codice:</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> exclude_post_content<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_search<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$pattern</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/OR\s*\(\w+\.post_content\s+LIKE\s*(\'[^\']+\')\s*\)/'</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$where</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$pattern</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #b1b100;">return</span> <span style="color: #000088;">$where</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_where'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'exclude_post_content'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>In pratica elimini la codizione di ricerca del contenuto dalla select che esegue normalmente WordPress. </p>
<p>Per le &#8216;tag&#8217; la questione è simile agli esempi che si trovano nell&#8217;artiolo, cioè userie il filtero <code class="codecolorer text default"><span class="text">pre_get_posts</span></code>. Ad esempio, se vuoi cercare solo negli articoli con tag &#8216;prima-tag&#8217;, usa:</p>
<div class="codecolorer-container php vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">function</span> search_filter<span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">is_search</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'tag'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'prima-tag'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$query</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'pre_get_posts'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'search_filter'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
]]></content:encoded>
	</item>
	<item>
		<title>Di: matteo</title>
		<link>http://www.undolog.com/2009/07/08/very-short-trick-wordpress-escludere-pagine-e-post-dalla-ricerca/#comment-5489</link>
		<dc:creator>matteo</dc:creator>
		<pubDate>Sat, 08 Oct 2011 22:43:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2146#comment-5489</guid>
		<description>Molto interessante. Io però avrei bisogno un&#039;altra cosa ancora: attualmente la ricerca effettua scansione anche sul testo della pagina/post. Come posso modificare la cosa perché non cerchi all&#039;interno del contenuto testuale ma si limiti ad esempio a cercare solo nel titolo e nelle tag?</description>
		<content:encoded><![CDATA[<p>Molto interessante. Io però avrei bisogno un&#8217;altra cosa ancora: attualmente la ricerca effettua scansione anche sul testo della pagina/post. Come posso modificare la cosa perché non cerchi all&#8217;interno del contenuto testuale ma si limiti ad esempio a cercare solo nel titolo e nelle tag?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Di: Undolog.com» Very short trick: Wordpress, escludere pagine e post &#8230;</title>
		<link>http://www.undolog.com/2009/07/08/very-short-trick-wordpress-escludere-pagine-e-post-dalla-ricerca/#comment-2277</link>
		<dc:creator>Undolog.com» Very short trick: Wordpress, escludere pagine e post &#8230;</dc:creator>
		<pubDate>Wed, 08 Jul 2009 16:00:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.undolog.com/?p=2146#comment-2277</guid>
		<description>[...] approfondire consulta articolo originale: Undolog.com» Very short trick: Wordpress, escludere pagine e post &#8230;  Articoli correlati: Very short trick: pagine padri e pagine figlie in Wordpress [...]</description>
		<content:encoded><![CDATA[<p>[...] approfondire consulta articolo originale: Undolog.com» Very short trick: WordPress, escludere pagine e post &#8230;  Articoli correlati: Very short trick: pagine padri e pagine figlie in WordPress [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

