Enabling Sessions in WordPress 3.0

If you need to manually enable the session globally, use this in your functions.php (I included a line for manually setting a session variable as an example, not required): add_action(‘init’, ‘session_manager’); function session_manager() { if (!session_id()) { session_start(); } $_SESSION[‘foo’] = ‘bar’; } and if you wanted to manually clear the session on an event … Read more

How to make custom bulk actions work on the media/upload page?

If you want to use your code, try this: If you want to check if the medias are attachments, you can try to use $_REQUEST[‘detached’] add_action( ‘load-upload.php’, ‘export_media_test’ ); function export_media_test() { if ( ! isset( $_REQUEST[‘action’] ) ) return; echo ‘Export Media’; if ( isset( $_REQUEST[‘detached’] ) ) { die( ‘No attachments’ ); } … Read more

How can I remove the sitename or homepage title from all page titles?

By default WordPress use _wp_render_title_tag to hook wp_head ( see here ) add_action( ‘wp_head’, ‘_wp_render_title_tag’, 1 ); This function is wrapper of wp_get_document_title to show title tag on theme if add_theme_support( ‘title-tag’ ); added in theme file functions.php ( commonly ). https://core.trac.wordpress.org/browser/tags/4.4.2/src/wp-includes/general-template.php#L944 If you see filter document_title_parts on function wp_get_document_title(), we can filter parameters that … Read more

Is it possible to change the attributes of a registered style or script before it fires?

Modify a registered style’s path I wanted to tweak the path to one of the WordPress admin stylesheets so i could keep requests down, and because it makes little sense to include two stylesheets, when the one i’m calling redefines all the styling in the stylesheet enqueued by WordPress. The idea is basically to re-point … Read more

Archive Listings Filtered by Date Values in a Custom Field/Post Meta?

As with many things in WordPress there are several ways to do what you want. I’m going to explain one of them. Remove the ‘year’, ‘monthnum’ and ‘day’ Query Variables You can modify the parameters to the query WordPress uses on the archive URLs inside the ‘pre_get_posts’ hook. Those parameters are captured as an associative … Read more