Forum
Search results outputs from all pages
Hello,
I am trying to only output results from the /blog/[...]
pages. This is my code:
<?php
$query = perch_get('q'); // 'q' query string argument e.g. search.php?q=apples
$opts = array(
'count'=>8,
'from-path'=>'blog/',
'excerpt-chars'=>300,
'paginate' => true,
'page-links' => true,
'page-link-style' => 'all',
'cache' => false,
);
perch_content_search($query, $opts);
?>
My problem is that the results from all pages are being shown.
Mike
Hi Mike
Did you try
'apps' => 'perch_blog'
as an option for the search function? I've not used it myself but this might help limit to the blog app.Jon
Hi Jonathan,
Thanks for the reply, unfortunately it does not work.
Mike
Hello Mike,
If you are looking to narrow the search by path, you would use
'from-path' => '/blog'
.If you are looking to narrow the search by the blog app, you would use
'apps' => ['PerchBlog']
.'from-path' => '/blog'
is not working for me, but'apps' => ['PerchBlog']
does work. Thank you, Hussein.from-path
refers to page content. Blog posts are coming from the Blog app, so you need theapps
option there.