admin管理员组

文章数量:1122846

I am creating a wordpress theme wth html and jquery. I want to add a data attribute to my pattern so that I can use jquery to control the behaviour. When I add a data attribute to my code, I get an error that an invalid property has been added. How do I fix this without using a plugin?

My pattern:

<?php

/**
* Title: Resume Layout
* Slug: portfolia/resume-default
* Categories: featured
*/
?>

<!-- wp:group {"metadata":{"categories":["featured"],"patternName":"portfolia/resume-default","name":"Resume Layout"},"className":"portfolia-resume-layout","layout":{"type":"flex","flexWrap":"nowrap","justifyContent":"center","verticalAlignment":"top"}} -->
<div class="wp-block-group portfolia-resume-layout">
<!-- wp:group {"className":"portfolia-sidebar"} -->
<div class="wp-block-group portfolia-sidebar">
 <!-- wp:buttons {"layout":{"type":"flex","orientation":"vertical"}} -->
 <div class="wp-block-buttons">
   <!-- wp:button {"backgroundColor":"black","textColor":"white","className":"portfolia-sidebar-item active","style":{"elements":{"link":{"color":{"text":"var:preset|color|white"}}}}} -->
   <div class="wp-block-button portfolia-sidebar-item active"><a
       class="wp-block-button__link has-white-color has-black-background-color has-text-color has-background has-link-color wp-element-button">

本文标签: How to add custom attributes to wordpress block theme