{"id":41,"date":"2023-08-08T04:51:11","date_gmt":"2023-08-08T04:51:11","guid":{"rendered":"https:\/\/directorist.com\/knowledge-base\/?post_type=docs&#038;p=41"},"modified":"2024-11-07T20:59:31","modified_gmt":"2024-11-07T20:59:31","password":"","slug":"directorist-bulk-assign-listings-expiration-date-and-never-expire","status":"publish","type":"docs","link":"https:\/\/directorist.com\/knowledge-base\/docs\/directorist-bulk-assign-listings-expiration-date-and-never-expire\/","title":{"rendered":"Directorist:  Bulk Assign Listings Expiration Date And Never Expire"},"content":{"rendered":"\n<p>There is a way to enable your directorist listings to edit the expiration date and assign &#8216;Never Expire&#8217; in bulk. Please follow the instructions given below to achieve this feature on your website.<\/p>\n\n\n\n<p>Please add the following code at the end of the &#8220;functions.php&#8221; file of the currently activated theme or child theme folder. It is always better to use a child theme for implementing custom codes. If you do not want to use theme files, you can use any &#8220;Code Snippet&#8221; plugin to implement the code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('bulk_edit_custom_box', 'directorist_custom_box_never_expire', 10, 2);\nadd_filter('quick_edit_custom_box', 'directorist_custom_box_never_expire', 10, 2);\nfunction directorist_custom_box_never_expire($column_name, $post_type)\n{\n    if (('atbdp_date' === $column_name) &amp;&amp; (ATBDP_POST_TYPE == $post_type)) {\n        ?&gt;\n        &lt;fieldset class=\"inline-edit-col-right\" style=\"margin-top: 0;\"&gt;\n            &lt;div class=\"misc-pub-section misc-pub-atbdp-never-expires\"&gt;\n                &lt;label&gt;\n                    &lt;input type=\"checkbox\" name=\"never_expire\" value=\"1\" \/&gt;\n                    &lt;strong&gt;Never Expires&lt;\/strong&gt;\n                &lt;\/label&gt;\n                &lt;div class=\"atbdp_expiry_date\"&gt;\n                    &lt;label&gt;&lt;strong&gt;Expiry Date&lt;\/strong&gt;&lt;\/label&gt;\n                    &lt;input type=\"datetime-local\" name=\"expiry_date\" \/&gt;\n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/fieldset&gt;\n&lt;?php\n    };\n}\n \nadd_action('save_post', 'directorist_custom_box_never_expire_save');\nfunction directorist_custom_box_never_expire_save($post_id)\n{\n \n    if (!is_admin()) {\n        return;\n    }\n \n    if (get_post_type($post_id) !== ATBDP_POST_TYPE) {\n        return;\n    }\n \n    \/\/ if our current user can't edit this post, bail\n    if (!current_user_can('edit_posts')) {\n        return;\n    }\n \n    \/\/ Make sure that it is set.\n    if (isset($_REQUEST&#091;'never_expire']) &amp;&amp; !empty($_REQUEST&#091;'never_expire'])) {\n        update_post_meta($post_id, '_never_expire', sanitize_text_field($_REQUEST&#091;'never_expire']));\n    }\n \n    if (isset($_REQUEST&#091;'expiry_date']) &amp;&amp; !empty($_REQUEST&#091;'expiry_date'])) {\n        update_post_meta($post_id, '_expiry_date', sanitize_text_field($_REQUEST&#091;'expiry_date']));\n        update_post_meta($post_id, '_never_expire', 0);\n    }\n}\n \nadd_action('admin_footer', function(){\n?&gt;\n    &lt;script&gt;\n        jQuery(document).ready(function($){\n            $('.misc-pub-atbdp-never-expires input&#091;name=\"never_expire\"]').change(function(){\n                if( $(this).is(\":checked\") ){\n                    $('.misc-pub-atbdp-never-expires .atbdp_expiry_date').hide();\n                    $('.misc-pub-atbdp-never-expires input&#091;name=\"expiry_date\"]').val('');\n                }else{\n                    $('.misc-pub-atbdp-never-expires .atbdp_expiry_date').show();\n                }\n            });\n        });\n    &lt;\/script&gt;\n&lt;?php\n});\n<\/code><\/pre>\n\n\n\n<p>After implementing the code successfully, when you try to bulk edit the listings from the admin panel you will find two new options to set the expiration date and never expire.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"463\" src=\"https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image-1024x463.png\" alt=\"\" class=\"wp-image-43\" srcset=\"https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image-1024x463.png 1024w, https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image-300x136.png 300w, https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image-768x347.png 768w, https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image-360x163.png 360w, https:\/\/directorist.com\/knowledge-base\/wp-content\/uploads\/sites\/7\/2023\/08\/image.png 1217w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Here&#8217;s a method to perform a bulk update of the expiration date. We believe this article will assist you in tailoring your website and enhancing its user-friendliness.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is a way to enable your directorist listings to edit the expiration date and assign &#8216;Never Expire&#8217; in bulk. Please follow the instructions given below to achieve this feature on your website. Please add the following code at the end of the &#8220;functions.php&#8221; file of the currently activated theme or child theme folder. It [&hellip;]<\/p>\n","protected":false},"author":4606,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[3],"doc_tag":[],"knowledge_base":[],"class_list":["post-41","docs","type-docs","status-publish","hentry","doc_category-custom-code"],"year_month":"2026-04","word_count":433,"total_views":"2469","reactions":{"happy":"7","normal":"0","sad":"4"},"author_info":{"name":"Mahfuzul Alam","author_nicename":"mahfuz","author_url":"https:\/\/directorist.com\/knowledge-base\/author\/mahfuz\/"},"doc_category_info":[{"term_name":"Custom Code","term_url":"https:\/\/directorist.com\/knowledge-base\/home\/non-knowledgebase\/custom-code\/"}],"doc_tag_info":[],"_links":{"self":[{"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/docs\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/users\/4606"}],"replies":[{"embeddable":true,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":0,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/docs\/41\/revisions"}],"wp:attachment":[{"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/doc_category?post=41"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/doc_tag?post=41"},{"taxonomy":"knowledge_base","embeddable":true,"href":"https:\/\/directorist.com\/knowledge-base\/wp-json\/wp\/v2\/knowledge_base?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}