{"id":1859,"date":"2016-07-09T00:26:52","date_gmt":"2016-07-09T00:26:52","guid":{"rendered":"http:\/\/themes.wpbeaches.com\/venobox\/?page_id=1859"},"modified":"2016-07-10T05:47:08","modified_gmt":"2016-07-10T05:47:08","slug":"add-a-data-attribute-to-a-wordpress-gallery","status":"publish","type":"post","link":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/","title":{"rendered":"Add a Data Attribute to a WordPress Gallery via jQuery"},"content":{"rendered":"<p>You can add a data attribute and value to a WordPress gallery via jQuery<\/p>\n<pre>jQuery(document).ready(function($){\r\n\r\n$('#gallery-1 a').each(function() {\r\n $(this).attr('data-gall', 'gallery-mine' );\r\n });\r\n\r\n});<\/pre>\n<p>So above we are targetting the <em>a<\/em> link tags that are the descendants of the <strong>gallery<\/strong> with an id of <em>#gallery-1<\/em><\/p>\n<p>They are then given a data attribute of <em>data-gall<\/em> and a value of <em>gallery-mine.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can add a data attribute and value to a WordPress gallery via jQuery jQuery(document).ready(function($){ $(&#8216;#gallery-1 a&#8217;).each(function() { $(this).attr(&#8216;data-gall&#8217;, &#8216;gallery-mine&#8217; ); }); }); So above we are targetting the a link tags that are the descendants of the gallery with an id of #gallery-1 They are then given a data attribute of data-gall and a &hellip; <a href=\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Add a Data Attribute to a WordPress Gallery via jQuery<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox\" \/>\n<meta property=\"og:description\" content=\"You can add a data attribute and value to a WordPress gallery via jQuery jQuery(document).ready(function($){ $(&#039;#gallery-1 a&#039;).each(function() { $(this).attr(&#039;data-gall&#039;, &#039;gallery-mine&#039; ); }); }); So above we are targetting the a link tags that are the descendants of the gallery with an id of #gallery-1 They are then given a data attribute of data-gall and a &hellip; Continue reading Add a Data Attribute to a WordPress Gallery via jQuery\" \/>\n<meta property=\"og:url\" content=\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\" \/>\n<meta property=\"og:site_name\" content=\"VenoBox LightBox\" \/>\n<meta property=\"article:published_time\" content=\"2016-07-09T00:26:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-07-10T05:47:08+00:00\" \/>\n<meta name=\"author\" content=\"wpbeaches\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"wpbeaches\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\"},\"author\":{\"name\":\"wpbeaches\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600\"},\"headline\":\"Add a Data Attribute to a WordPress Gallery via jQuery\",\"datePublished\":\"2016-07-09T00:26:52+00:00\",\"dateModified\":\"2016-07-10T05:47:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\"},\"wordCount\":59,\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\",\"url\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\",\"name\":\"Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox\",\"isPartOf\":{\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#website\"},\"datePublished\":\"2016-07-09T00:26:52+00:00\",\"dateModified\":\"2016-07-10T05:47:08+00:00\",\"author\":{\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600\"},\"breadcrumb\":{\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/themes.wpbeaches.com\/venobox\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Manual Markup\",\"item\":\"https:\/\/themes.wpbeaches.com\/venobox\/manual-markup\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Add a Data Attribute to a WordPress Gallery via jQuery\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#website\",\"url\":\"https:\/\/themes.wpbeaches.com\/venobox\/\",\"name\":\"VenoBox LightBox\",\"description\":\"Just another responsive WordPress jQuery lightbox plugin\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/themes.wpbeaches.com\/venobox\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600\",\"name\":\"wpbeaches\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/021b74a55ed390e01233c4ee2c720d1e308e3b995da5750145afce5788731137?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/021b74a55ed390e01233c4ee2c720d1e308e3b995da5750145afce5788731137?s=96&d=mm&r=g\",\"caption\":\"wpbeaches\"},\"description\":\"Share a little biographical information to fill out your profile. This may be shown publicly. Share a little biographical information to fill out your profile. This may be shown publicly. Share a little biographical information to fill out your profile. This may be shown publicly.\",\"url\":\"https:\/\/themes.wpbeaches.com\/venobox\/author\/wpbeaches\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/","og_locale":"en_US","og_type":"article","og_title":"Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox","og_description":"You can add a data attribute and value to a WordPress gallery via jQuery jQuery(document).ready(function($){ $('#gallery-1 a').each(function() { $(this).attr('data-gall', 'gallery-mine' ); }); }); So above we are targetting the a link tags that are the descendants of the gallery with an id of #gallery-1 They are then given a data attribute of data-gall and a &hellip; Continue reading Add a Data Attribute to a WordPress Gallery via jQuery","og_url":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/","og_site_name":"VenoBox LightBox","article_published_time":"2016-07-09T00:26:52+00:00","article_modified_time":"2016-07-10T05:47:08+00:00","author":"wpbeaches","twitter_card":"summary_large_image","twitter_misc":{"Written by":"wpbeaches"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#article","isPartOf":{"@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/"},"author":{"name":"wpbeaches","@id":"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600"},"headline":"Add a Data Attribute to a WordPress Gallery via jQuery","datePublished":"2016-07-09T00:26:52+00:00","dateModified":"2016-07-10T05:47:08+00:00","mainEntityOfPage":{"@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/"},"wordCount":59,"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/","url":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/","name":"Add a Data Attribute to a WordPress Gallery via jQuery - VenoBox LightBox","isPartOf":{"@id":"https:\/\/themes.wpbeaches.com\/venobox\/#website"},"datePublished":"2016-07-09T00:26:52+00:00","dateModified":"2016-07-10T05:47:08+00:00","author":{"@id":"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600"},"breadcrumb":{"@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/themes.wpbeaches.com\/venobox\/add-a-data-attribute-to-a-wordpress-gallery\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/themes.wpbeaches.com\/venobox\/"},{"@type":"ListItem","position":2,"name":"Manual Markup","item":"https:\/\/themes.wpbeaches.com\/venobox\/manual-markup\/"},{"@type":"ListItem","position":3,"name":"Add a Data Attribute to a WordPress Gallery via jQuery"}]},{"@type":"WebSite","@id":"https:\/\/themes.wpbeaches.com\/venobox\/#website","url":"https:\/\/themes.wpbeaches.com\/venobox\/","name":"VenoBox LightBox","description":"Just another responsive WordPress jQuery lightbox plugin","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/themes.wpbeaches.com\/venobox\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/22e5a59937f10e7c75a1a29ead249600","name":"wpbeaches","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/themes.wpbeaches.com\/venobox\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/021b74a55ed390e01233c4ee2c720d1e308e3b995da5750145afce5788731137?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/021b74a55ed390e01233c4ee2c720d1e308e3b995da5750145afce5788731137?s=96&d=mm&r=g","caption":"wpbeaches"},"description":"Share a little biographical information to fill out your profile. This may be shown publicly. Share a little biographical information to fill out your profile. This may be shown publicly. Share a little biographical information to fill out your profile. This may be shown publicly.","url":"https:\/\/themes.wpbeaches.com\/venobox\/author\/wpbeaches\/"}]}},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p7HFXn-tZ","_links":{"self":[{"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/posts\/1859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/comments?post=1859"}],"version-history":[{"count":2,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/posts\/1859\/revisions"}],"predecessor-version":[{"id":1869,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/posts\/1859\/revisions\/1869"}],"wp:attachment":[{"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/media?parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/categories?post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/themes.wpbeaches.com\/venobox\/wp-json\/wp\/v2\/tags?post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}