@@ -169,15 +169,14 @@ function get_license_search_query() {
169169 $ query = sanitize_text_field ( $ query );
170170
171171 return $ query ;
172-
173172 }
174173}
175174
176175
177176// Meta Block Field Filter Date
178177add_filter ( 'meta_field_block_get_block_content ' , 'osi_filter_meta_block_date_output ' , 10 , 4 );
179178function osi_filter_meta_block_date_output ( $ content , $ attributes , $ block , $ post_id ) {
180- if ( is_numeric ( $ content ) && 8 == strlen ( $ content ) ) {
179+ if ( is_numeric ( $ content ) && 8 === strlen ( $ content ) ) {
181180 $ content = DateTime::createFromFormat ( 'Ymd ' , $ content )->format ( 'M Y ' );
182181 }
183182 return $ content ;
@@ -187,17 +186,37 @@ function osi_filter_meta_block_date_output( $content, $attributes, $block, $post
187186add_action ( 'pre_get_posts ' , 'osi_press_mentions_by_publication_date ' );
188187function osi_press_mentions_by_publication_date ( $ query ) {
189188 if ( ! is_admin () && $ query ->is_main_query () ) {
190- if ( is_post_type_archive ( 'press-mentions ' ) ) {
189+ if ( is_post_type_archive ( 'press-mentions ' ) ) {
191190 $ query ->set ( 'meta_key ' , 'date_of_publication ' );
192191 $ query ->set ( 'orderby ' , 'meta_value_num ' );
193- $ query ->set ( 'order ' , 'DESC ' );
194- $ query ->set ( 'meta_query ' , array (
192+ $ query ->set ( 'order ' , 'DESC ' );
193+ $ query ->set (
194+ 'meta_query ' ,
195195 array (
196- 'key ' => 'date_of_publication ' ,
197- 'type ' => 'numeric ' ,
198- )
199- ) );
196+ array (
197+ 'key ' => 'date_of_publication ' ,
198+ 'type ' => 'numeric ' ,
199+ ),
200+ )
201+ );
200202 }
201203 }
202204 return $ query ;
203- }
205+ }
206+
207+ /**
208+ * Renders the "Created" and "Last modified" string for a page.
209+ */
210+
211+ function osi_the_page_dates () {
212+ if ( ! is_home () && ! is_front_page () ) {
213+ $ max_date = '2023-02-01 ' ; // February 1, 2023
214+ $ created = get_the_date ( 'F j, Y ' );
215+ $ modified = get_the_modified_date ( 'F j, Y ' );
216+
217+ if ( strtotime ( $ created ) < strtotime ( $ max_date ) ) {
218+ // Post was created before the 'max date'.
219+ echo sprintf ( '<h4 class="page_dates">Page created on %1$s | Last modified on %2$s</h4> ' , esc_html ( $ created ), esc_html ( $ modified ) );
220+ }
221+ }
222+ }
0 commit comments