{"id":996,"date":"2025-03-24T14:28:14","date_gmt":"2025-03-24T14:28:14","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-to-set-business-hours-to-yes-by-default\/"},"modified":"2025-04-03T15:24:35","modified_gmt":"2025-04-03T14:24:35","slug":"how-to-set-business-hours-to-yes-by-default","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/how-to-set-business-hours-to-yes-by-default\/","title":{"rendered":"How to set business hours to YES by default"},"content":{"rendered":"\n<p>Here is a code snippet to set GeoDirectory Business hours to &#8216;yes&#8217; in the add listing form by default<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/**\n * Set Business Hours to open as default.\n *\/\nfunction gd_snippet_200118_business_hours_set_default( $html, $cf ) {\n\tglobal $gd_post;\n\n\tif ( ! empty( $html ) &amp;&amp; ! empty( $cf ) &amp;&amp; ! empty( $gd_post ) &amp;&amp; ! empty( $gd_post-&gt;post_status ) &amp;&amp; $gd_post-&gt;post_status == &#039;auto-draft&#039; ) {\n\t\t$html = str_replace( &#039;});&lt;\/script&gt;&#039;, &#039;$(&quot;input#&#039; . $cf&#091;&#039;htmlvar_name&#039;&#093; . &#039;_f_active0&quot;).prop(&quot;checked&quot;, true).trigger(&quot;change&quot;);});&lt;\/script&gt;&#039;, $html );\n\t}\n\n\treturn $html;\n}\nadd_filter( &#039;geodir_custom_field_input_business_hours&#039;, &#039;gd_snippet_200118_business_hours_set_default&#039;, 20, 2 );<\/code><\/pre>\n\n\n\n<p>If you are using <strong>Ayecode legacy design<\/strong>.&nbsp;&nbsp;You can use the below code.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/**\n * Set Business Hours to open as default.\n *\/\nfunction gd_snippet_200118_business_hours_set_default( $html, $cf ) {\n\tglobal $gd_post;\n\n\tif ( ! empty( $html ) &amp;&amp; ! empty( $cf ) &amp;&amp; ! empty( $gd_post ) &amp;&amp; ! empty( $gd_post-&gt;post_status ) &amp;&amp; $gd_post-&gt;post_status == &#039;auto-draft&#039; ) {\n\t\t$html = str_replace( &#039;});&lt;\/script&gt;&#039;, &#039;$(&quot;input#&#039; . $cf&#091;&#039;htmlvar_name&#039;&#093; . &#039;_f_active_1&quot;).prop(&quot;checked&quot;, true).trigger(&quot;change&quot;);});&lt;\/script&gt;&#039;, $html );\n\t}\n\treturn $html;\n}\nadd_filter( &#039;geodir_custom_field_input_business_hours&#039;, &#039;gd_snippet_200118_business_hours_set_default&#039;, 20, 2 );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here is a code snippet to set GeoDirectory Business hours to &#8216;yes&#8217; in the add listing form by default If you are using Ayecode legacy design.&nbsp;&nbsp;You can use the below code.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-996","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/996\/revisions"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=996"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}