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

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

register_activation_hook for multiple functions

My approach to this would be to have a start_activation() method that calls the other methods. register_activation_hook( __FILE__, array( ‘my_plugin_loader’, ‘start_activation’ ) ); class my_plugin_loader { function start_activation() { $this->func1(); // or self::func1(); $this->func2(); // self::func2(); for static methods } function func1() { // do stuff } function func2() { // do other stuff } … Read more

How to override woocommerce.css?

Your code actually looks good, according to the WooCommerce Documentation. It may simply be related to usage in a child theme, but I think that would still work. For reference, here is what I use to replace the default WooCommerce CSS files. This only disables the “general” styling (colors, buttons, etc) but keeps the structuring … Read more

Function to display post by specific author

Here is how I would solve your problem since $authordata is not a variable that I recognize as a WordPress global. function display_post_via_specific_author( $nicename ) { // Grab the user by `user_nicename` $author = get_user_by( ‘slug’, $nicename ); $posts = get_posts( array( ‘author’ => $author->ID, ‘posts_per_page’ => 5 ) ); $output=”<h5>Latest Posts by Sam</h5>”; $output … Read more