Change the listing category block title

Im trying to use ACF (is there a better way?) to change the category name as it appears on the category blocks. For example: subcategory name, Texas red apples, appear on category block as Texas Red Apples, but I just want the name to say Texas (were it links to the category/subcategory).

I already have my custom field on dashboard>listings>categories edit/create new category.

Here is code I have, which doesnt work, but I think im close, if anyone could help. Thank you

add_filter(
'hivepress/v1/templates/Listing_Categories_View_Page',
function( $blocks, $template ) {
if (get_field('custom_anchor_text')) {
  $content = get_field('
custom_anchor_text');
    return hivepress()->helper->merge_trees(
            [ 'blocks' => $blocks ],
            [
                'blocks' => [
                    'page_content' => [
                        'blocks' => [
                            'listing_category_name' => [
                                    'type'    => 'content',
                                    'content' => $content,
                                    '_order'  => 1,
                            ],
                        ],
                    ],
                ],
            ]
        )['blocks'];
} // end if
},
1000,
2
);

Sorry for the delay. Please try using this hook instead hivepress/v1/templates/listing_category_view_block. You can also override the category title template part via a child theme and add all the logic there, inside the template part PHP file.

thanks. unfortunatly i just end up with a blank page were categories go.

add_filter(
‘hivepress/v1/templates/listing_category_view_block’,
function( $blocks, $template ) {
if (get_field(‘custom_anchor_text’)) {
$content = get_field(‘custom_anchor_text’);
return hivepress()->helper->merge_trees(
[ ‘blocks’ => $blocks ],
[
‘blocks’ => [
‘page_content’ => [
‘blocks’ => [
‘listing_category_name’ => [
‘type’ => ‘content’,
‘content’ => $content,
‘_order’ => 1,
],
],
],
],
]
)[‘blocks’];
} // end if
},
1000,
2
);

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.