<?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>divi &#8211; danisanchez.net</title>
	<atom:link href="https://danisanchez.net/tag/divi/feed/" rel="self" type="application/rss+xml" />
	<link>https://danisanchez.net</link>
	<description></description>
	<lastBuildDate>Sat, 04 Jan 2020 08:17:57 +0000</lastBuildDate>
	<language>es</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://danisanchez.net/wp-content/uploads/2026/07/cropped-favicon-32x32.png</url>
	<title>divi &#8211; danisanchez.net</title>
	<link>https://danisanchez.net</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Divi, hacer que el módulo de búsqueda funcione en Custom Posts</title>
		<link>https://danisanchez.net/divi-hacer-que-el-modulo-de-busqueda-funcione-en-custom-posts/</link>
					<comments>https://danisanchez.net/divi-hacer-que-el-modulo-de-busqueda-funcione-en-custom-posts/#comments</comments>
		
		<dc:creator><![CDATA[dani.sanchez]]></dc:creator>
		<pubDate>Sat, 04 Jan 2020 08:17:57 +0000</pubDate>
				<category><![CDATA[Divi]]></category>
		<category><![CDATA[Tutoriales]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[divi]]></category>
		<category><![CDATA[wordpress]]></category>
		<guid isPermaLink="false">https://www.gestionatuweb.net/?p=6384</guid>

					<description><![CDATA[Por defecto, el módulo de búsqueda de Divi solo ofrece resultados provenientes de páginas y entradas (los tipos de post por defecto de WordPress). Pero si nuestra web tiene contenidos personalizados, es posible que necesitemos ampliar las búsquedas a este tipo de contenidos. Este artículo también está disponible en vídeo: Para integrar custom posts en [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Por defecto, el módulo de búsqueda de Divi solo ofrece resultados provenientes de páginas y entradas (los tipos de post por defecto de WordPress).</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img fetchpriority="high" decoding="async" width="451" height="515" src="https://danisanchez.net/wp-content/uploads/2020/01/imagen.png" alt="" class="wp-image-6385" srcset="https://danisanchez.net/wp-content/uploads/2020/01/imagen.png 451w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-263x300.png 263w" sizes="(max-width: 451px) 100vw, 451px" /></figure></div>



<p class="wp-block-paragraph">Pero si nuestra web tiene contenidos personalizados, es posible que necesitemos ampliar las búsquedas a este tipo de contenidos.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Este artículo también está disponible en vídeo:</p></blockquote>



<iframe src="https://www.youtube-nocookie.com/embed/JRguPerjnHE" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" width="100%" height="315" frameborder="0"></iframe>



<div style="height:25px" aria-hidden="true" class="wp-block-spacer"></div>



<p class="wp-block-paragraph">Para integrar custom posts en el módulo de búsqueda tenemos que añadir la siguiente función al archivo de funciones de Divi (se recomienda crear un child theme), o en nuestro propio <a href="https://danisanchez.net/wordpress-crear-nuestro-propio-plugin-de-funciones/" target="_blank" rel="noreferrer noopener" aria-label="plugin de funciones (opens in a new tab)">plugin de funciones</a>.</p>



<pre class="wp-block-code"><code>function custom_remove_default_et_pb_custom_search() { 
    remove_action( 'pre_get_posts', 'et_pb_custom_search' ); 
    add_action( 'pre_get_posts', 'custom_et_pb_custom_search' ); 
} 
add_action( 'wp_loaded', 'custom_remove_default_et_pb_custom_search' ); 
 
 function custom_et_pb_custom_search($query = false){ 
    if(is_admin() || ! is_a($query, 'WP_Query') || ! $query-&gt;is_search){ 
        return; 
    } 
 
    if(isset($_GET&#91;'et_pb_searchform_submit'])){ 
    $postTypes = array(); 
 
        if(!isset($_GET&#91;'et_pb_include_posts']) &amp;&amp; ! isset($_GET&#91;'et_pb_include_pages'])){ 
            $postTypes = array('post'); 
        } 
    
        if(isset($_GET&#91;'et_pb_include_pages'])){ 
            $postTypes = array('page'); 
        } 
    
        if(isset($_GET&#91;'et_pb_include_posts'])){ 
        $postTypes&#91;] = 'post'; 
        } 
    
        /* Comienza a añadir tus custom posts*/ 
        $postTypes&#91;] = 'vehiculos'; 
        /* Fin añadir tus custom posts*/ 
    
        $query-&gt;set('post_type', $postTypes); 
    
        if(! empty($_GET&#91;'et_pb_search_cat'])){ 
                $categories_array = explode(',', $_GET&#91;'et_pb_search_cat']); 
            $query-&gt;set('category__not_in', $categories_array); 
        } 
    
        if(isset($_GET&#91;'et-posts-count'])){ 
            $query-&gt;set( 'posts_per_page', (int) $_GET&#91;'et-posts-count']); 
        } 
    } 
} </code></pre>



<p class="wp-block-paragraph">Presta atención a la línea:</p>



<pre class="wp-block-code"><code>/* Comienza a añadir tus custom posts*/ 
        $postTypes&#91;] = 'vehiculos'; 
/* Fin añadir tus custom posts*/</code></pre>



<p class="wp-block-paragraph">Donde &#8216;vehiculos&#8217; es el identificador del custom posts que queremos añadir a la búsqueda. Si necesitamos añadir más tipos de posts, solo tenemos que asignarlos al $postTypes[] línea a línea:</p>



<pre class="wp-block-code"><code>$postTypes&#91;] = 'mi_custom_post';
$postTypes&#91;] = 'otro_custom_post';
...</code></pre>



<p class="wp-block-paragraph">En esta web de vehículos, si intentamos buscar el nombre de un coche sin integrar el código anterior, no obtendremos ningún resultado de búsqueda.</p>



<figure class="wp-block-image size-large"><img decoding="async" src="https://danisanchez.net/wp-content/uploads/2020/01/imagen-1-1-1024x390.png" alt="" class="wp-image-6386"/></figure>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="148" src="https://danisanchez.net/wp-content/uploads/2020/01/imagen-2-1024x148.png" alt="" class="wp-image-6387" srcset="https://danisanchez.net/wp-content/uploads/2020/01/imagen-2-1024x148.png 1024w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-2-300x43.png 300w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-2-768x111.png 768w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-2-1536x223.png 1536w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-2.png 1587w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">En cambio, integrando el código anterior:</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="357" src="https://danisanchez.net/wp-content/uploads/2020/01/imagen-3-1024x357.png" alt="" class="wp-image-6388" srcset="https://danisanchez.net/wp-content/uploads/2020/01/imagen-3-1024x357.png 1024w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-3-300x105.png 300w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-3-768x268.png 768w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-3-1536x536.png 1536w, https://danisanchez.net/wp-content/uploads/2020/01/imagen-3.png 1587w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Recuerda que puedes adquirir Divi desde mi enlace de afiliado con <strong>descuentos de hasta el 20%</strong>, así me ayudarás a seguir creando contenidos sobre Divi en mi Blog y en <a rel="noreferrer noopener" aria-label="Youtube (opens in a new tab)" href="https://www.youtube.com/gestionatuweb" target="_blank"><strong>Youtube</strong></a>.</p>


]]></content:encoded>
					
					<wfw:commentRss>https://danisanchez.net/divi-hacer-que-el-modulo-de-busqueda-funcione-en-custom-posts/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
