Below, you’ll find a detailed guide on how to add the WP Custom Fields Search Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the WP Custom Fields Search Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the WP Custom Fields Search Plugin and the shortcodes it provides:
"WP Custom Fields Search is a powerful WordPress plugin that enables you to easily search through custom fields, enhancing your site's search functionality."
- [wp_custom_fields_search]
- [wpcfs-preset]
WP Custom Fields Search [wp_custom_fields_search] Shortcode
The wp-custom-fields-search plugin shortcode is a powerful tool that allows you to display a specific preset search form on your WordPress site. It uses an ob_start() function to turn on output buffering, ensuring that no output is sent from the script other than headers. This is followed by the show_preset function which displays the preset search form. The output is then stored in the $content variable and returned, making it display on the website.
Shortcode: [wp_custom_fields_search]
Parameters
Here is a list of all possible wp_custom_fields_search shortcode parameters and attributes:
preset
– Specifies the preset search form to display
Examples and Usage
Basic example – A simple usage of the wp_custom_fields_search shortcode that calls a preset search form with the id of 0.
[wp_custom_fields_search preset=0 /]
Advanced examples
Using the shortcode to display a custom search form by referencing a preset ID. This allows you to create multiple search forms and call them individually by their preset ID.
[wp_custom_fields_search preset=5 /]
Another advanced usage of the shortcode could involve creating a custom search form with multiple presets. This is useful if you want to create a complex search form that includes multiple fields or conditions.
[wp_custom_fields_search preset="1,2,3,4,5" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wp_custom_fields_search]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode("wp_custom_fields_search",array($this,"shortcode"));
Shortcode PHP function:
function shortcode($atts){
$atts = shortcode_atts(array(
"preset"=>"0"
),$atts);
ob_start();
$this->show_preset($atts['preset']);
$content = ob_get_contents();
ob_end_clean();
return $content;
}
Code file location:
wp-custom-fields-search/wp-custom-fields-search/plugin.php
WP Custom Fields Search [wpcfs-preset] Shortcode
The WP Custom Fields Search plugin shortcode is used to display custom field search forms. This shortcode fetches a preset search form based on the ID provided in the shortcode attribute. It starts an output buffer, runs the ‘show_preset’ function with the given ID, captures the output, and returns it as content.
Shortcode: [wpcfs-preset]
Parameters
Here is a list of all possible wpcfs-preset shortcode parameters and attributes:
id
– Specifies the unique identifier for the preset search form
Examples and Usage
Basic example – The shortcode is used to display a preset search form by referencing its ID.
[wpcfs-preset id=1 /]
PHP Function Code
In case you have difficulties debugging what causing issues with [wpcfs-preset]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode("wpcfs-preset",array($this,"preset_shortcode"));
Shortcode PHP function:
function preset_shortcode($atts){
$atts = shortcode_atts(array(
"id"=>"0"
),$atts);
ob_start();
$this->show_preset($atts['id']);
$content = ob_get_contents();
ob_end_clean();
return $content;
}
Code file location:
wp-custom-fields-search/wp-custom-fields-search/plugin.php
Conclusion
Now that you’ve learned how to embed the WP Custom Fields Search Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply