Set featured image randomly from WordPress Database on post submission

Here is a way: // listen for post being published add_action(‘publish_post’, ‘dreis_random_featured_image’); function dreis_random_featured_image() { global $post; // find one random image $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => ‘image’, ‘post_status’ => ‘inherit’, ‘posts_per_page’ => 1, ‘orderby’ => ‘rand’ ); $random_image = new WP_Query($args); foreach($random_image as $image){ // set as thumbnail set_post_thumbnail($post->ID, $image->ID); } … Read more

Globally register styles but enqueue them selectively

If you want the stylesheets registered in the backend, use the admin_enqueue_scripts action. function wp94156_register_styles() { wp_register_style( ‘your-stylesheet’, get_stylesheet_directory_uri() . ‘/your-stylesheet.css’, $deps, // optional $version // optional ); // since you only want it registered, we won’t enqueue it } add_action( ‘admin_enqueue_scripts’, ‘wp94156_register_styles’ );

resetting permalinks after changing page names

Not 100% what you mean. Apologies if this is obvious but… if just want to change the parent page title, and have that reflected in all the link structures you’d change the permalink for the page, just underneath the page title. Or is it something different?

SEO smart plugin not working for words ending with ä, ö, å

The author is using string functions for single-byte encodings: $url = substr($line, $lastDelimiterPos + 1 ); $keywords = substr($line, 0, $lastDelimiterPos); But in WordPress everything is encoded in UTF-8, a multi-byte encoding. So each time you have a character in your keywords that needs more than one byte, something gets lost. File a bug report … Read more

Adding widgets to header and footer from plugin

Actually including that code in your theme template files is the only surefire way to include those widgets in various themes. It’s also the best to get them where you want them. Alternatively, you could accomplish this using hooks, but that relies on your themes actually calling the hook, and in the proper location. The … Read more