Reputation: 1
I saw that similar questions have already been asked and I tested everything they answered.
the answer that partially solved my problem was:
global $wp_query;
$args = array_merge( $wp_query->query, array( 'post_type' => 'post' ) );
query_posts( $args );
but I'm using a theme that search needs to return type 'manga' and it doesn't. I tried with page and with post and it worked but with manga it didn't.
Someone knows how to fix it?
Here's all the code:
query, array( 'post_type' => 'manga' ) ); query_posts( $args ); ?><div class="c-search-header__wrapper" style="<?php echo esc_attr($search_header_background != '' ? $search_header_background : 'background-image: url(' . get_parent_theme_file_uri( '/images/bg-search.jpg' ) . ');'); ?>">
<div class="container">
<div class="search-content">
<form role="search" method="get" class="search-form <?php echo (esc_html($madara_ajax_search) == 'on' ? 'ajax' : '');?>">
<label> <span class="screen-reader-text"><?php esc_html_e( 'Search for:', 'madara' ); ?></span>
<input type="search" class="search-field" placeholder="<?php esc_html_e( 'Search...', 'madara' ); ?>" value="<?php echo esc_attr( $s ); ?>" name="s">
</label> <input type="submit" class="search-submit" value="<?php esc_html_e( 'Search', 'madara' ); ?>">
</form>
</div>
</div>
</div>
<div class="c-page-content">
<div class="content-area">
<div class="container">
<div class="row">
<div class="main-col col-md-12 sidebar-hidden">
<?php get_template_part( 'html/main-bodytop' ); ?>
<!-- container & no-sidebar-->
<div class="main-col-inner">
<?php
if ( have_posts() ) {
?>
<div class="search-wrap">
<div class="tab-wrap">
<div class="c-blog__heading style-2 font-heading">
<h4>
<i class="<?php madara_default_heading_icon(); ?>"></i>
<?php echo sprintf( _n( '%s result', '%s results', $wp_query->found_posts, 'madara' ), $wp_query->found_posts ); ?>
</h4>
</div>
</div>
<!-- Tab panes -->
<div class="tab-content-wrap">
<div class="c-blog-listing">
<div class="c-blog__inner">
<div class="c-blog__content">
<div id="loop-content" class="page-content-listing">
<?php
/* Start the Loop */
$index = 1;
set_query_var( 'madara_post_count', madara_get_post_count() );
while ( have_posts() ) : the_post(); ?><?php
set_query_var( 'madara_loop_index', $index );
get_template_part( 'html/loop/content', get_post_format() );
$index ++;
?>
<?php endwhile; ?>
</div>
</div>
<?php
//Get Pagination
$madara_pagination = new App\Views\ParsePagination();
$madara_pagination->renderPageNavigation( '#loop-content', 'html/loop/content' );
?>
</div>
</div>
</div>
</div>
</div>
<?php
} else {
?>
<div class="search-wrap no-results not-found">
<div class="results_content">
<div class="icon-not-found">
<i class="icon ion-android-sad"></i>
</div>
<div class="not-found-content">
<p><?php esc_html_e( 'No matches found. Try a different search...', 'madara' ); ?></p>
</div>
</div>
</div>
<?php
}
get_template_part( 'html/main-bodybottom' ); ?>
</div>
</div>
</div>
</div>
</div></div>
Upvotes: 0
Views: 57
Reputation: 894
I suspect, assuming 'manga' is a custom post type, that you want to look at sommething like https://thomasgriffin.com/how-to-include-custom-post-types-in-wordpress-search-results/
Try
function a_include_custom_post_types_in_search_results( $query ) {
if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) {
$query->set( 'post_type', array( 'post', 'manga') );
}
}
add_action( 'pre_get_posts', 'a_include_custom_post_types_in_search_results' );
Chances are with it or something like it in functions.php you won't need to do much chanching of your theme's search teplates.
Upvotes: 0