File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
web/app/themes/mitlib-parent Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,38 @@ function setup_scripts_styles() {
258
258
}
259
259
add_action ( 'wp_enqueue_scripts ' , 'Mitlib\Parent\setup_scripts_styles ' );
260
260
261
+ /**
262
+ * Creates a nicely formatted and more specific title element text
263
+ * for output in head of document, based on current view.
264
+ *
265
+ * @param string $title Default title text for current view.
266
+ * @param string $sep Optional separator.
267
+ * @return string Filtered title.
268
+ */
269
+ function customize_title ( $ title , $ sep ) {
270
+ global $ paged , $ page ;
271
+
272
+ if ( is_feed () ) {
273
+ return $ title ; }
274
+
275
+ // Add the site name.
276
+ $ title .= get_bloginfo ( 'name ' );
277
+
278
+ // Add the site description for the home/front page.
279
+ $ site_description = get_bloginfo ( 'description ' , 'display ' );
280
+ if ( $ site_description && ( is_home () || is_front_page () ) ) {
281
+ $ title = "$ title $ sep $ site_description " ;
282
+ }
283
+
284
+ // Add a page number if necessary.
285
+ if ( $ paged >= 2 || $ page >= 2 ) {
286
+ $ title = "$ title $ sep " . sprintf ( 'Page %s ' , max ( $ paged , $ page ) );
287
+ }
288
+
289
+ return $ title ;
290
+ }
291
+ add_filter ( 'wp_title ' , 'Mitlib\Parent\customize_title ' , 10 , 2 );
292
+
261
293
/**
262
294
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
263
295
*/
You can’t perform that action at this time.
0 commit comments