Hello, I need to create sample listings for users to get some inspiration when creating their own. What would be the best way to do this? I tried to make a listing attribute checkbox with “sample _listing” and then reference it in snippet but with no luck. It would be best if everything as design stayed the same as normal listing, but if you tried to click on any button like book now or send message it would show small notification that you can’t do that. Is there anything for this? Or how do I make sample listing most effectively? Thank you
Hi,
The easiest option is to create a category, for example, a sample listing, and indicate in the listing title that it is a sample listing. And if, for example, a message is sent, you can ignore it as an administrator. All other options will require custom implementation.
I hope this is helpful to you.
That doesn’t work for me at all. I have 8 categories with subcategories and for each main category I need to make one sample listing. Making another category for those listings is not a good solution to this problem. This is something that could have some simple snippet to do this. There would be many unnecessary emails about new messages and bookings if it’s not restricted. Any other ideas? I very much need to create sample listings.
Unfortunately there’s no sample listing feature at the moment. If I understand correctly, you want to create listings hidden in search but visible for other vendors, and these listings should forbid any actions (e.g. purchasing or sending a message). There are possible workarounds:
- Changing the listing date to the most early date so it will show up at the end in search
- Using separate categories for such listings as suggested by Andrii (e.g. a single Samples category) to indicate them
- Adding “[sample]” or other text to the listing title to indicate that it’s a sample, or you can also add a custom Checkbox attribute and use a label-like display format for it, also adding it to the Primary display area (so when checked, it would show the “sample” label)
- Adding custom CSS to block all the clicks on sample listing pages - we can provide a sample for blocking clicks (let me know if this works for you) but not custom error messages - please consider adding a disclaimer that it’s a sample listing to its description
Hope this helps & Happy Holidays
Your last point is exactly what I need. It should look as any other user created listing but with restriction to message or booking for the specific listing. Thank you very much, and happy holidays
Also need the same for requests, since when first starting the website, there must be sample request already made and with restricted functions for users. Thank you very much, happy holidays
Please try using this CSS snippet:
.single-hp_listing.postid-123 .hp-page__content,
.single-hp_listing.postid-123 .hp-page__sidebar {pointer-events:none}
Replace 123 with the ID of this sample listing (you can check its ID in the browser address bar while editing it in WordPress/Listings). Then all the links and buttons will not be clickable within the listing page area (the header and footer, menus will still be ok). This is the easiest solution, you can also add some text to the listing title and/or description to indicate that it’s a sample listing and it’s just for display, to avoid confusion.
You can use the same snippet for requests if you replace all the “listing” words to “request” in it.
Hope this helps
That’s a brilliant solution. Thank you Ihor! Your help is always spot on. I really appreciate your guys work. Have a great times!
It works great on the listing itself when you open it, but I noticed when you preview the listings in categories for example/searching on grid, the message button on the card itself in the footer is still opening chat. Would it be possible to also disable that message button? How do I target it? Can keep the add to favorites button, but make the message button unclickable. Thank you
No worries, I’m glad I could help.
Unfortunately there’s no simple way to do the same for the listing blocks as they don’t have unique CSS classes based on IDs, but I can provide a PHP snippet to exclude them from the listing search pages (or you can try using a separate category for this) - let me know if this works for you.
That PHP snippet would be awesome. Don’t need that message button/icon on those sample listings when it’s disabled inside of them. Thank you
Sorry for the delay.
Unfortunately there’s no easy way to disable specific elements, but you can try excluding these sample listings from category/search pages (replace 1,2,3 with sample listing IDs):
add_action(
'pre_get_posts',
function( $query ) {
if ( is_admin() || ( ! $query->is_main_query() && ! $query->get( 'hp_main' ) ) ) {
return;
}
$query->set( 'post__not_in', [ 1, 2, 3 ] );
},
1000
);
Hope this helps
Hello Ihor, that doesn’t really solve the problem for me. Your previous solution for inside of the listing/after you click on it was brilliant, it disabled the panel with all the buttons like booking and message. But I also need some way to either disable or completely remove either only the “message” button, which would be perfect, or also “add to favorites” button that’s next to it in the same container when you search listings, after clicking on category.
Your current solution doesn’t work for me because it suggest to disable the whole listing from showing, and I need the listing to be shown next to random user generated listings. And not hide it completely from search.
Even when you disable message inside of listing preview with your first solution, user can still click on the message button on the listings search/in categories.
Are there any other solutions/creative ideas to this problem? Because without it the first solution doesn’t completely work. Thank you very much
Please try this PHP snippet instead, it adds a unique ID to each listing block:
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function ( $blocks, $template ) {
$listing = $template->get_context( 'listing' );
if ( $listing ) {
$blocks = hivepress()->template->merge_blocks(
$blocks,
[
'listing_container' => [
'attributes' => [
'id' => 'listing-' . $listing->get_id(),
],
],
]
);
}
return $blocks;
},
1000,
2
);
Then you can use a similar CSS snippet as suggested for the listing page previously, e.g. to block the whole listing (replace 123 with the listing ID):
#listing-123{pointer-events:none}
Or just the listing actions:
#listing-123 .hp-listing__actions {pointer-events:none}
This is again a brilliant solution. Thank you very much Ihor, your help is greatly appreciated and spot on! Now it restricts clicking on the stuff inside of the listing and also on the block itself, awesome.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.