• Resolved shefa7

    (@shefa7)


    Hi, can this search be used on custom post types? I’m looking to create a search of custom post type of books with options to select various search criteria such as year published, author etc.

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Epsiloncool

    (@epsiloncool)

    Hi @shefa7

    Yes, you can use this plugin, because it’s an extension of WP_Query() (integrated WP search).

    You can modify either default search (which runs when you enter a search query in the standard Search widget) or add your own searches with separate widgets and even have multiple searches on your website.

    This is a short instruction on how can you modify your MAIN search:
    (add this code to your functions.php)

    ——->8——————-

    add_action('pre_get_posts', function(&$wpq)
    {
        if ($wpq->is_main_query() && (!is_admin()) && is_search()) {
            // Here you can modify default WP_Query() parameters
            $wpq->set('post_type', array('post', 'page', 'mycustom_post_type', '.....'));
            // ... add other parameters
        }
    }, 8);

    ————–8<————-

    In case you don’t want to modify your main search, you can add new searches. Here is how you can do it:
    (again, add this code to your functions.php)
    ——–>8——————-
    // Let’s add new search preset

    add_action ('init', function()
    {
    	global $wpfts_core;
    
    	if ((!is_object($wpfts_core)) || (!$wpfts_core)) {
    		return;
    	}
    	
    	if (method_exists($wpfts_core, 'AddWidgetPreset')) {
    		$wpfts_core->AddWidgetPreset('mypreset1', array(
    			'title' => 'My Preset 1',
    			'filter' => 'mypreset1',
    			'results_url' => '/',
    			'autocomplete_mode' => 1,
    		));
    	}
    }, 255);
    
    // And now we need to add one more method to process new preset
    add_action('wpfts_pre_get_posts', function(&$wpq, $wdata)
    {
    	if ($wdata['id'] == 'mypreset1') {
    		// Let's set up specific parameters for this module
    		$wpq->set('post_type', array('mycustom_post_type'));
    	}
    }, 20, 2);

    ————–8<————-

    After that, you need to use another widget “WPFTS :: Live Search” and select your preset in widget’s config.

    Nothing too complex. If you will need some help – please write me back or read this documentation:

    https://fulltextsearch.org/documentation/

    Thanks!

    Thread Starter shefa7

    (@shefa7)

    Thanks for the reply @epsiloncool. Do you offer services for implementing this custom code?
    As I said above I’m looking to have a search bar with various filters based on custom post’s fields and am looking for someone to implement / code it for me.
    If so how much would you charge?

    Thanks

    • This reply was modified 3 years, 10 months ago by shefa7.
    Plugin Author Epsiloncool

    (@epsiloncool)

    Hi @shefa7

    We can develop modifications with the plugin for free but do not offer custom developments for websites.

    I think you need to find someone else who can develop such a form for you, sorry.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom post types’ is closed to new replies.