Closed carolineclara closed 7 years ago
Hello,
you basically need first to register a new title action for that button to appear. Within that title action you can name your button and add additional attributes as well as the action which needs to get fired on a click on it.
See here the default example: https://github.com/wpsight/wpcasa/blob/master/wpcasa/includes/class-wpsight-template.php#L442
Ok, I understand but I'll have an error beacause I will have two identcal function no ?
So I create a new title action :
<?php wpsight_listing_title( $listing->ID ); ?>
Then where do I have to go to creat an other label and an other template for that function without create a duplicate error ?
Thank you !
No, you have to filter through and add your custom action like so:
add_filter( 'wpsight_get_listing_actions', 'my_custom_action' );
function my_custom_action( $actions ) {
$actions['custom'] = array(
'label' => __( 'Custom', 'wpcasa' ),
'name' => false,
'id' => false,
'class' => 'actions-custom action-link',
'href' => esc_url( add_query_arg( array( 'print' => absint( $post_id ) ), get_permalink( $post_id ) ) ),
'target' => false,
'icon' => false,
'atts' => false,
'priority' => 20,
'callback' => false
);
return $actions
}
Hi,
So, I put that code in my function.php and now I have my two buttons, that good ! But, when I click on my custom button, nothing happen. It doesn't open a "print" window... I want a print window but with an other template than the listing-print.php.
Actually my link is ?print=0 for the new button, it's not getting the post id right ?
Sorry, but I'm a little bit lost, thanks for your help !
You need to define an action for it, and further you need to hook your template up. Unfortunately this would be to much to get handled here. You'd better get in touch with a webdeveloper who can handle this for you.
Hi, I'll try to be as clear as i can. In single listing we have a print button. I want an other one to can create an other print view with other informations inside. I already create an other template than linsting-print.php but I don't now how to call it now. Can you help ? Thank you !