Powerful Workflows: Create Custom Links to WP Sheet Editor with Pre-applied Searches

Hello! Today, we’re diving into a powerful, lesser-known feature of WP Sheet Editor that can revolutionize your workflows: creating custom URLs that automatically open the spreadsheet with specific search filters applied.

This is a game-changer for developers, agencies, and power users. Imagine creating a button on a product page that opens all its variations in the editor, building a custom admin dashboard with quick links to view “posts pending review” or “products with low stock,” or integrating the editor seamlessly with other plugins. With custom search URLs, this is not only possible but also surprisingly easy.

The Magic Behind the URL: wpse_custom_filters

The core of this feature is the wpse_custom_filters URL parameter. You can build a link to any spreadsheet and pass this parameter with an array of search conditions. The editor will read these conditions on page load and automatically run the search for you.

In PHP, you’ll typically use WordPress functions like add_query_arg() to construct your URL safely. Here’s the basic structure:


<?php
// 1. Get the base URL for the spreadsheet page (e.g., 'product', 'post', etc.)
$spreadsheet_url = VGSE()->helpers->get_editor_url( 'product' );
// 2. Define your search filters as an array
$filters = array(
'keyword' => 'T-Shirt',
);
// 3. Build the final URL with the filters and a security nonce
$final_url = esc_url(
add_query_arg(
array(
// The array of filters
'wpse_custom_filters' => $filters,
// A security nonce is required
'wpse_custom_filters_nonce' => wp_create_nonce( 'bep-nonce' ),
),
$spreadsheet_url
)
);
// You can now use $final_url in a link
echo '<a href="' . $final_url . '">View all published T-Shirts</a>';
?>

Let’s break down the different types of filters you can apply.

Simple Filtering Examples: Your Everyday Searches

1. Search by Keyword

This is the most basic search. It looks for the keyword in the title and content.


$filters = array(
'keyword' => 'My Awesome Product',
);

2. Find Specific Post IDs

Load a specific set of items by providing their IDs in a comma-separated string.


$filters = array(
'post__in' => '12, 45, 183',
);

3. Filter by Category, Tag, or Custom Taxonomy

Use the apply_to key to filter by taxonomy terms. The format is an array of strings, with each string being 'taxonomy_slug--term_slug' .


// Find WooCommerce products in the 'clothing' category
$filters = array(
'apply_to' => array( 'product_cat--clothing' ),
);

Dive Deeper: Advanced Filtering with meta_query

For truly powerful searches, you can filter by any database field using meta_query . This gives you granular control to query based on post data (like title or date) or post meta (like price, SKU, or any custom field).

The structure is an array of search conditions. Each condition is itself an array containing four keys:

  • key : The database field name (e.g., post_title , _price ).
  • compare : The comparison operator (e.g., = , != , > , LIKE , starts_with ).
  • value : The value to search for.
  • source : Specifies where the key exists. Use 'post_data' for core post fields (from the wp_posts table) or 'meta' for custom fields (from the wp_postmeta table) or ‘terms’ for taxonomy searches.

1. Find WooCommerce Products with a Regular Price > $50


$filters = array(
'meta_query' => array(
array(
'key'     => '_regular_price',
'value'   => 50,
'compare' => '>',
'source'  => 'meta'
)
)
);

2. Find Posts with a Title Starting With “Tutorial:”


$filters = array(
'meta_query' => array(
array(
'key'     => 'post_title',
'value'   => 'Tutorial:',
'compare' => 'starts_with',
'source'  => 'post_data'
)
)
);

3. Find All Out of Stock Products


$filters = array(
'meta_query' => array(
array(
'key'     => '_stock_status',
'value'   => 'outofstock',
'compare' => '=',
'source'  => 'meta'
)
)
);

Special Case: WooCommerce Products and Variations

A common request is to open the editor showing a specific variable product and all its variations. You can achieve this by combining a post ID search (using the parent product’s ID) with one special parameters to display variations along the parent.


// Assuming $product_id contains the ID of the parent variable product
$filters = array(
// Search by the parent product ID to find the parent and its children
'post__in'               => $product_id,
// This tells the frontend to load the sheet with variations visible
'wc_display_variations' => 'yes',
);

Bonus Tip: Auto-Export Your Search Results

Want to go one step further? You can create a link that not only filters the data but also automatically opens the “Export” dialog and triggers an export. Just add wpse_auto_export=1 to your URL. This is perfect for creating one-click custom reports.


// Build your URL with filters as shown before
$url_with_filters = add_query_arg(...);
// Now, add the auto export parameter
$final_url = add_query_arg('wpse_auto_export', '1', $url_with_filters);
echo '<a href="' . esc_url($final_url) . '">Download Report</a>';

Conclusion: What Will You Build?

This feature opens up a world of possibilities for customizing the WordPress admin and creating highly efficient workflows for you or your clients. From custom dashboards to deep integrations with other plugins, you now have the tool to make WP Sheet Editor the central hub for your data management.

We’re excited to see what you create. Happy coding!

Do you need help?

You can receive instant help in the live chat during business hours, or you can contact us and we will help you via email.