This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Search page issue

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #55155
    alan_uew5alan_uew5
    Participant

    Hi. Hoping you can help. I have (although this is turned off for now) it set up to search a custom post type (act) and custom post taxonomy (event_category). This works well when viewing those results from the panel that appears after search however when I go to the search results page the styling is incorrect for the taxonomy due to the way the search.php page is set up.

    Basically I need the styling of the taxonomy result to be different to that of the custom post type and for a few elements to change. Any ideas how I could achieve this?

    Thanks in advance, Alan

    #55158
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi,

    The search results page in wordpress is specifically built to only display post type results. The plugin tries to “hack” those other results by sending fake posts with a modified url and titles as a placeholder.

    You have two options:

    1. To not display those results there using a custom code snippet. If it is okay to ignore them on the result page, then I can provide a small custom code snippet to exclude them when the results are directed to the search results page. Let me know if you need that.

    2. To use the theme functions to modify the search.php file to fetch the fields from the live search (such as the images) on the results page. This requires custom coding though, so I only recommend doing that if you are comfortable with theme editing. These may or may not work, highly depends on how the search results page is built so I can’t guarantee anything.

    #55164
    alan_uew5alan_uew5
    Participant

    You cannot access this content.

    #55165
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Not sure, it can be a theme thing. It might be optimal to exlcude them from the results page overall to avoid any conflicts generally:

    add_filter(
    	'asp_query_args',
    	function ( $args ) {
    		if ( !$args['_ajax_search']  ) {
    			$args['search_type'] = array('cpt');
    		}
    		return $args;
    	}
    );

    Try adding this code via the Code Snippets (or similar) plugin or to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    #55167
    alan_uew5alan_uew5
    Participant

    You cannot access this content.

    #55169
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Looks good to me!

    The number of results on the plugin’s end is controlled under the Search Sources -> Limits panel: https://i.imgur.com/8O5MCFn.png
    That should do the trick 🙂

    #55170
    alan_uew5alan_uew5
    Participant

    Perfect. Really appreciated your quick replies and help with this.

    #55171
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You are very welcome 🙂 I will keep this topic open for a few days in case something comes up.

    If you like the plugin and have not rated already, feel free to leave a rating on the wordpress plugin repository, it’s greatly appreciated.

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.