Site logo

[Resolved] Possible to add class and other data-elements to tag

Home Forums Support [Resolved] Possible to add class and other data-elements to tag

Home Forums Support Possible to add class and other data-elements to tag

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2181274
    Eugene

    Hi there

    2 part question:

    1) Is it possible to add a class to an <a> tag directly in the editor? I could only get the class on the parent <p> element: https://prnt.sc/1DrS-jWCxmZd

    2) More advanced: Is there a way to add data-attributes to <a> tags? Example:
    <a class="villa-list-item enquire-modal-listing" data-villa="Villa Boma" data-action="Enquire Now" data-location="Listing" target="_self" href="#enquire-now-popup" data-lity=""></a>

    #2181279
    David
    Staff
    Customer Support

    Hi there,

    the block editor doesn’t allow for that.
    You would need to switch to the Code Editor ( 3 dot menu in top bar ) to edit the HTML.

    WP may not like that – and if thats the case then you would need to use a HTML block.

    #2181281
    Eugene

    Thanks!

    #2181300
    David
    Staff
    Customer Support

    You’re welcome

    #2472133
    Webber

    Hi I have to do same things. But I want to add by function.php. When i try with this edit as html , it fails and asked to “attempt recovery and effect was gone. I have to use Generatepress blocks and creating a button with custom data id and type in it. Can you please help in this regards ?

    #2472286
    David
    Staff
    Customer Support

    Hi there,

    are you using GenerateBlocks Pro ?
    As it provides Data Attributes in the GB Blocks Advanced panel.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.