{"id":312,"date":"2025-03-13T10:36:56","date_gmt":"2025-03-13T10:36:56","guid":{"rendered":"https:\/\/documentation.iqonic.design\/graphina\/?p=312"},"modified":"2025-03-13T10:36:58","modified_gmt":"2025-03-13T10:36:58","slug":"retrieving-dynamic-data-using-wordpress-filters","status":"publish","type":"post","link":"https:\/\/documentation.iqonic.design\/graphina\/retrieving-dynamic-data-using-wordpress-filters\/","title":{"rendered":"Retrieving Dynamic Data Using WordPress Filters"},"content":{"rendered":"<div class=\"nolwrap\">\n<p>The <strong>WordPress filter functionality<\/strong> allows users to fetch and modify dynamic data effortlessly. By utilizing the <code>graphina_extra_data_option<\/code> filter, you can integrate custom data into Graphina charts and widgets.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Use the WordPress Filter for Dynamic Data<\/strong><\/h2>\n\n\n\n<p>To enable this feature, add the <strong>Graphina filter<\/strong> to any WordPress file. A common practice is to include it in the <strong>functions.php<\/strong> file of your active theme.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Example Use Cases<\/strong><\/h4>\n\n\n\n<p>The filter provides structured data for various chart types, including:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Pie, Donut, Radial, Polar Charts<\/strong> \u2013 Returns category-based data for these visualizations.<\/li>\n\n\n\n<li><strong>Area, Column, Brush, Mixed, Line, Radar, Distributed Column Charts<\/strong> \u2013 Returns multi-series data.<\/li>\n\n\n\n<li><strong>Data Tables (Lite &amp; Advanced)<\/strong> \u2013 Returns tabular data with headers and body content.<\/li>\n\n\n\n<li><strong>Counters<\/strong> \u2013 Configures counter elements with speed, start, and end values.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Implementation Notes<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ensure the <strong>Graphina filter<\/strong> is correctly added to your theme\u2019s <code>functions.php<\/code>.<\/li>\n\n\n\n<li>Use this filter to customize chart data dynamically without modifying each chart manually.<\/li>\n\n\n\n<li>Adjust priority and accepted arguments as needed to fit your project requirements.<\/li>\n<\/ul>\n\n\n\n<p>This feature enhances the flexibility of <strong>Graphina dynamic charts<\/strong>, allowing seamless integration of real-time WordPress data.<\/p>\n\n\n\n<p>\/\/$data -&gt; sample data<\/p>\n\n\n\n<p>\/\/$type -&gt; type of widget (line, area)<\/p>\n\n\n\n<p>\/\/$settings -&gt; elementor setting array<\/p>\n\n\n\n<p>\/\/$widgetId -&gt; Id of elementor widget ( each widget have a unique id)<\/p>\n\n\n\n<p>add_filter(\u2018graphina_extra_data_option\u2019,function($data, $type, $settings,$widgetId){<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($type == \u2018pie\u2019 || $type == \u2018donut\u2019 || $type == \u2018radial\u2019 || $type == \u2018polar\u2019 ){<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return [<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018series\u2019 =&gt; [52, 62,48,52 ],<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018category\u2019 =&gt; &nbsp;[ \u201cJan\u201d, \u201cFeb\u201d, \u201cMar\u201d, &nbsp;\u201cApr\u201d ],<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018total\u2019=&gt;542<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;];<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($type == \u2018area\u2019 || $type == \u2018column\u2019 || $type == \u2018brush\u2019 || $type == \u2018mixed\u2019 || $type == \u2018line\u2019 || $type == \u2018radar\u2019 || $type == \u2018distrubuted_column\u2019){<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return [ \u2018series\u2019 =&gt; [<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018name\u2019 =&gt; \u2018elem\u2019,<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018data\u2019 =&gt; [ 52,58,585,14]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;],<\/p>\n\n\n\n<p>\u2018category\u2019 =&gt; [ \u2018Jan\u2019, \u2018Feb\u2019, \u2018Mar\u2019, \u2018Apr\u2019 ]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;];<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if($type === \u2018data_table_lite\u2019 || $type == \u2018advance-datatable\u2019){<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return [<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018body\u2019 =&gt; [<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [\u2018abc\u2019 , \u2018xyz\u2019],<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [\u2018rtl\u2019 , \u2018yzr\u2019]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ],<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; \u2018header\u2019 =&gt; [\u2018firstname\u2019,\u2019lastname\u2019]<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ];<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if($type == \u2018counter\u2019){<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;return [ [\u2018title\u2019 =&gt; \u2018filter\u2019,<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u2018speed\u2019 =&gt; 1200,<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u2018start\u2019 =&gt; 0,<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u2018end\u2019 =&gt; 8025,<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\u2018multi\u2019 =&gt; []<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;]];<\/p>\n\n\n\n<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<\/p>\n\n\n\n<p>&nbsp; }, $priority, $accepted_args);<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Fetch Data From Any Data Source With Graphina Data Filter | Iqonic Design\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/Iwle9hEgJ-o?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><\/figure>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>The WordPress filter functionality allows users to fetch and modify dynamic data effortlessly. By utilizing the graphina_extra_data_option filter, you can integrate custom data into Graphina charts and widgets. How to Use the WordPress Filter for Dynamic Data To enable this feature, add the Graphina filter to any WordPress file. A common practice is to include [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"parent":235,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-312","post","type-post","status-publish","format-standard","hentry","category-graphina"],"featured_image_src":null,"author_info":{"display_name":"wordpressadminiq","author_link":"https:\/\/documentation.iqonic.design\/graphina\/author\/wordpressadminiq\/"},"children":[],"_links":{"self":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/comments?post=312"}],"version-history":[{"count":1,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/312\/revisions"}],"predecessor-version":[{"id":314,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/312\/revisions\/314"}],"up":[{"embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/posts\/235"}],"wp:attachment":[{"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/media?parent=312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/categories?post=312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/documentation.iqonic.design\/graphina\/wp-json\/wp\/v2\/tags?post=312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}