Index Logo

Adding custom buttons to archives

Index provides a filter for adding your own buttons to any archive, instead of the default WordPress table view. While it’s not possible to port over existing buttons added to the default WordPress table view, you can quickly add those buttons with a standard WordPress filter.

Adding the filter

The filter should be formatted like this:

add_filter("blt-{$post_type}-actions", $yourFunction);

Make sure to replace $post_type with your post type (ex: ‘posts’, ‘page’, etc) and $yourFunction with whatever function you want to use. 

Passing new buttons to your function

Your function should take the passed in array of buttons as the single parameter (by default an empty array), and append any new ones you want to display at the top of the page. 

This example adds an anchor link with the label ‘Click Me’, and an id of custom-button.

function yourFunction($actions) {
   $actions[] = array(
       'label' => 'Click Me', 
       'atts' => array( // atts is any number of regular HTML attributes you want to add to the button
           'href' => '#',
           'id' => 'custom-button'
       )
   );

   return $actions;
}

Making your button do something

While Index is a javascript powered archive, your custom buttons are inserted via PHP to avoid issues with event bubbling in javascript (for example: adding click events to elements that don’t exist yet).

If you are porting over a button from the default WordPress table, then filling out the atts array with the same values from your other code should be enough to make the button work! If you are making a brand new button, then the process is up to you for how you want your button to function.

Get started for free

Try Index free for 14 days and see for yourself why it's the best interface for managing your WordPress content — no credit card required.

Start your free trial