I am new to wordpress and a beginner coder, and i was searching around the net, found solutions but still does not work.
I have custom post type named dlm_download
, and my custom search template not working
I added the following to my functions.php
file - the code is from this answer by @Ronald.
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_search && $post_type == 'dlm_download' )
{
return locate_template('archive-download.php');
}
return $template;
}
add_filter('template_include', 'template_chooser');
Created the archive-download.php
and when i preform my custom search, i get the url like this mysite.com/?dlm_download=699
nothing happens i just get redirected to my home page.
Could please someone tell what i am doing wrong?
archive-download.php
file is located, etc. All in an edit.