Docs & Support

Learn about all Business Directory’s features and get support from our amazing customer success team.

wpbdp-listing-buttons

Heads up!
This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don’t provide support for code customizations or 3rd party development.

Make adjustments to the buttons before they are displayed on the page. This includes the edit and delete buttons on the single listing page, and on the page that shows all listings.

Usage

add_filter( 'wpbdp-listing-buttons', 'change_bd_buttons', 10, 2 );

Parameters

  • $buttons (string) The HTML to show.
  • $listing_id (int) The id of the listing.

Examples

Add a ‘View’ button

This example will add a button to View the listing from the ‘All Listings’ page.

add_action('wp', function() {
  add_filter( 'wpbdp-listing-buttons', 'bd_add_view_button', 10, 2 );
});

function bd_add_view_button ( $buttons, $listing_id ) {
  if ( is_singular( WPBDP_POST_TYPE ) || ! wpbdp_user_can( 'view', $listing_id ) ) {
    // Don't add the button if already on the single page.
    return $buttons;
  }

  $buttons .= '<a class="wpbdp-button button view-listing" href="' . esc_url( get_permalink() ) . '">View</a>';

  return $buttons;
}
Was this article helpful? *

This article may contain affiliate links. Once in a while, we earn commissions from those links. But we only recommend products we like, with or without commissions.

In this article

    We have a small, but amazing team of dedicated people who are committed to helping you achieve your goals and project requirements.


    Copyright © 2010-2025 S11 Directories, LLC.

    Join 20,000+ using Business Directory Plugin to build website directories fast. Get Started