anyway to take a snippet of the listing description and place it on the category listings block, maybe with ellipses. this would greatly help with SEO.
thanks
anyway to take a snippet of the listing description and place it on the category listings block, maybe with ellipses. this would greatly help with SEO.
thanks
Hi,
If I understand you correctly, please check the solution in this topic Add description to listings block
āI hope this is helpful to you.
thank you for the code, exactly what i needed and much appreciated. i modified slightly to control output amount by adding
$excerpt = wp_trim_words($description, 20); // Adjust the number of words as needed
add_filter(
'hivepress/v1/templates/listing_view_block/blocks',
function ($blocks, $template) {
$listing = $template->get_context('listing');
if ($listing && $listing->get_description()) {
$description = $listing->get_description();
$excerpt = wp_trim_words($description, 25); // Adjust the number of words as needed
$blocks = hivepress()->helper->merge_trees(
['blocks' => $blocks],
[
'blocks' => [
'listing_details_primary' => [
'blocks' => [
'custom_listing_block_description' => [
'type' => 'content',
'content' => '<p>' . esc_html($excerpt) . '</p>',
'_order' => 20,
],
],
],
],
]
)['blocks'];
}
return $blocks;
},
1000,
2
);
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.