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;
}

Related Articles

Need Support?

Can't find the answer you're looking for?
Contact Support