Add an option to like and comment about ads(products) in Wpadverts plugin
-
Hi,
I am new to wordpress, and trying Wpadverts plugin to create a classified website, and
i would like to add an option to like the ads(visible to other users also how many liked), and
comment about the ads(also visible to other users). Please suggest a way to achive this
-
Hi,
- currently i am afraid we do not really have an option to like/bookmark ads, but we are planning to create such extension or integrate with a plugin that allows it.
- you can go to the wp-admin / Classifieds / Options / Core / Types panel, edit Classifieds, in the Supports field check “Comments” and the “Automatically enable comments when Ad is saved in the database.” checkbox and save the settings. Now each Ad added after making these changes will allow posting comments.
thanks @gwin ,
I am able to add the comment option now.
- Any other plugins that can be used to add the “like” option??
2. Is there a possibility to add the sellers microsoft teams link (in the contact section) ??(suppose the classified website is linked with an organisation)
3. On what basis does the search option work? ( because i added a product in the bike category, but when i searched with the keyword bike, that product was not visible)
- This reply was modified 1 year, 4 months ago by tagnavi.
- i am not aware of any that would work out-of-box with WPAdverts
- you can add a new contact button by adding the code below in your theme functions.php file
add_filter( "wpadverts/block/details/contact-options", function( $options ) { $options["msteam"] = array( "text" => "MsTeam", "icon" => "fas fa-phone-alt", "class" => "my", "type" => "secondary", "order" => 1, "options" => array( "mobile" => "text-and-icon", "desktop" => "text-and-icon" ), "attr" => [ "onclick" => "window.location. ] ); return $options; },100000); add_filter( "wpadverts/block/details/atts", function( $atts ) { $atts["contact"] = $atts["contact"] ?? array(); $atts["contact"][] = array( "name" => "msteam" ); return $atts; });
By default this button will just redirect to https://example.com/ website so you need to program for it some functionality.
3. this is the default WP search by keyword meaning it will search by default in the title and description only.
Thanks @gwin
The above code displays an option as MSteam, but i am not able to locate where the seller can enter their teams link.
While adding a new ad, in the contact information section, only contact person, email, and phone number fields are there.
There may be multiple users posting ads, so need a field in the contact information section, to add the user’s(seller) microsoft teams link.
Hi,
link field you can add either using the Custom Fields extension https://wpadverts.com/extensions/custom-fields/ or if you are familiar with PHP programming you can add this field using Forms API https://wpadverts.com/doc/custom-fields/
thanks @gwin ,
That helped me in adding a custom field in the classified.
i have a requirement like , in the contact button(the code u have given above ) of microsoft teams, it should automatically check the sellers email and redirect to the microsoft teams chat corresponding to that email id. please help me in achiveing this. (different ads have different sellers)
(same like using mailto: it redirects to sending mails, here it is required to open the teams chat , so that the selling user and buyer can chat in teams)
add_filter( "wpadverts/block/details/contact-options", function( $options ) { $options["msteam"] = array( "text" => "MsTeam", "icon" => "fas fa-phone-alt", "class" => "my", "type" => "secondary", "order" => 1, "options" => array( "mobile" => "text-and-icon", "desktop" => "text-and-icon" ), "attr" => [ "onclick" => "window.location. ] ); return $options; },100000); add_filter( "wpadverts/block/details/atts", function( $atts ) { $atts["contact"] = $atts["contact"] ?? array(); $atts["contact"][] = array( "name" => "msteam" ); return $atts; });
in the above code, i am able to redirect to the chat in teams, but what should be replaced with ‘[email protected]’ to get that particular ad post’s seller email id?
Hi,
you should be able to pull the email address used when posting an Ad with the below code
$email = get_post_meta( get_the_ID(), "adverts_email", true );
Can u please specify where the above code should be placed?
It should be something like this
add_filter( "wpadverts/block/details/contact-options", function( $options ) { $email = get_post_meta( get_the_ID(), "adverts_email", true ); $options["msteam"] = array( "text" => "MsTeam", "icon" => "fas fa-phone-alt", "class" => "my", "type" => "secondary", "order" => 1, "options" => array( "mobile" => "text-and-icon", "desktop" => "text-and-icon" ), "attr" => [ "onclick" => "window.location. ] ); return $options; },100000); add_filter( "wpadverts/block/details/atts", function( $atts ) { $atts["contact"] = $atts["contact"] ?? array(); $atts["contact"][] = array( "name" => "msteam" ); return $atts; });
thanks @gwin
that worked and satisfied the requirement,
Can i get a reference to the doc, where i can understand about the code(above) and the parameters that are used in that, so that it helps me in future while making changes in icons or adding any other contact options .
and also, i used Like-Dislike plugin to add the like option to the ads, but even after enabling the like option for classified post type, no changes is displayed in the frontend, do i need to make any other changes??
- This reply was modified 1 year, 4 months ago by tagnavi.
- the “wpadverts/bloc/…” filters are new ones and we do not really have them documented i am afraid
- you can put this button after the contact options by adding the code below in your theme functions.php file
add_action( "wpadverts/block/details/tpl/end", function( $post_id ) { echo do_shortcode(sprintf('[posts_like_dislike id="%d"]', $post_id ) ); }, 1000 );
thanks @gwin
- The topic ‘Add an option to like and comment about ads(products) in Wpadverts plugin’ is closed to new replies.