Change the URL field Display

Hi HivePress,

I have a quick question. I created an Attribute called Website Link and the field name is website_link for simplicity to be displayed when someone is posting a listing and added to the page.

I added the words “Website: %value%” to the display and it’s working to display the URL that doesn’t look great on the Listing since everything else is pretty clean on the listing page. So, I created a Code Snippet using a number of different attempts of code to change the URL to “Click Here” that should be pretty simple, but for some reason the snippet isn’t working. Here’s the last code that I did and I’m wondering if I’m just in the wrong place for the plugin. Some of the ways I’ve tried it break the site all together, but this one doesn’t, it just doesn’t work. I’m thinking I’m just in the wrong spot within hivepress for the filter. Can you please advise?

Thank you.

 add_filter('hivepress/v1/templates/listing_view_block', 'customize_website_link_in_listing', 10, 2);

function customize_website_link_in_listing($template, $listing) {
    $website_link = hivepress()->get_template()->get_value($listing, 'website_link');

    if ($website_link) {
        // Modify the display of the website link
        $template['blocks']['website_link'] = '<a href="' . esc_url($website_link) . '" target="_blank" rel="nofollow">Click Here</a>';
    }

    return $template;
}

Update: I solved this issue. I didn’t realize that I could HTML code into the Display → Format field. I put this code in and it solved the issue: <a href="%value%" target="_blank">click here</a>
and it worked fine. Thank you.

Next Stop: is creating a code snippet for the Description Field that will allow for the Wordpress Toolbar, so users can Bold Text, etc.

The Code Snippet plugin with the TinyMCE code combined with the Advanced Editor Tools plugin allowed me to create a toolbar for the Description Box with a bunch of additional functionality. I just wanted to let anyone know if they are trying to offer front-end editing features for descriptions.

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