Change the “Default Avatar” admin option via functions.php

You can just update the option field avatar_default to your new image url: add_filter( ‘avatar_defaults’, ‘mytheme_default_avatar’ ); function mytheme_default_avatar( $avatar_defaults ) { $avatar = get_option(‘avatar_default’); $new_avatar_url = get_template_directory_uri() . ‘/images/default_avatar.png’; if( $avatar != $new_avatar_url ) { update_option( ‘avatar_default’, $new_avatar_url ); } $avatar_defaults[ $new_avatar_url ] = ‘Default Avatar’; return $avatar_defaults; }

Custom Sidebar only on single post

In additon to wordpresser answer, you can also call to get_sidebar(‘sidebar-aside-content’); only in the template files where you want the sidebar be displayed. For example, if you include <?php get_sidebar(‘sidebar-aside-content’); ?> in “theme_folder/single.php” file, the sidebar will be displayed only in single posts. For example. In functions.php: //Register your sidebar add_action( ‘widgets_init’, ‘my_widgets_init’ ); function … Read more

Random Featured Image Based on Category

First of all when you call the get_image function pass the post categories slugs as param. Edit your autoset_featured function replacing … } else { set_post_thumbnail($post->ID, get_image()); } … with: … } else { $cat_slugs = wp_get_post_terms($post->ID, ‘event-categories’, array(“fields” => “slugs”)); $image = get_image( $cat_slugs ); if ( image ) set_post_thumbnail($post->ID, $image); } … Then … Read more

Including php files within template

My questions is, does this file get executed when browsing from the front end? Well, yes and no. Your file will be included on the front end when using the theme in question, but as your code is hooked to admin-only hooks, nothing really executes. The file is read but the code doesn’t do anything … Read more

Get my site session in wordpress?

WordPress doesn’t use PHP session ($_SESSION). If you want to use it you need to do at your own. For example: add_action(‘init’, ‘wpse_session_start’, 1); function wpse_session_start() { if(!session_id()) { session_start(); } } But, if you want is to get the user id of the current user, you can use get_current_user_id(): <?php $user_ID = get_current_user_id(); ?>