wrap a span tag around author’s post count

It doesn’t appear that wp_list_authors() supplies an appropriate hook to modify anything unfortunately. The next best thing would be to just do a string replace and hope for the best :/ $start_wrapper=”<span class=”author-post-count”>”; // Set our wrapper start tag $end_wrapper=”</span>”; // Set our wrapper end tag $author_html = wp_list_authors( array( // Get Author HTML ‘optioncount’ … Read more

Incrementing PHP variable onclick to display posts by month

Try registering a function handling ajax calls first. // For logged out users add_action( ‘wp_ajax_nopriv_wp280265_pagination’, ‘wp280265_pagination’ ); // For logged in users add_action( ‘wp_ajax_wp280265_pagination’, ‘wp280265_pagination’ ); Define the function. function wp280265_pagination() { $month = $_POST[‘month’]; $year = $_POST[‘year’]; if ($month != ” && $year != ”) get_posts($month, $year); } Define JavaScript. (function($) { $(document.body).on(‘click’, ‘#previous’, … Read more

Different SMTP based on domain

I believe what you need is the phpmailer_init action hook. Here is an something you can do. add_action( ‘phpmailer_init’, ‘custom_smtp_settings’ ); function custom_smtp_settings( $phpmailer ) { $phpmailer->isSMTP(); switch ($_SERVER[‘HTTP_HOST’]) { case ‘example1.com’: //name only, no http $phpmailer->Host=”smtp.example1.com”; $phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate $phpmailer->Port = 25; $phpmailer->Username=”example1″; $phpmailer->Password … Read more

get users search not working with array

get_users looks for an exact match for the value in search in the email address, URL, ID, username or display_name fields… it doesn’t look in the first name field. As you can’t search the first name directly, you could instead look for people with a username or display name that starts with it by using … Read more

blank white page when post/update/change option etc

Your function to call the sidebar “needs to be called” and also requires an id and should be in this format: add_action( ‘widgets_init’, ‘your_custom_sidebar’ ); function your_custom_sidebar() { register_sidebar( array( ‘name’ => __( ‘Footer Sidebar’, ‘your_theme_lang’ ), ‘id’ => ‘footer-sidebar’, ‘description’ => __( ‘Some description’, ‘your_theme_lang’ ), ‘before_widget’ => ‘<div class=”col-md-3 col-sm-6 footer-col”>’, ‘after_widget’ => … Read more

Trouble with a php code that adds a log in/log out button [closed]

I’m not sure why the space is a bad idea. Here is the code you would need with a space for the login: $items .= ‘<li><a href=”‘ . get_permalink( woocommerce_get_page_id( ‘myaccount’ ) ) . ‘”>Log In </a></li>’; seems a simple solution. IF you want to try css, it’s relatively simple as well. change the same … Read more

Automatically Add Page Links to Nav Menu

Turns out is_plugin_active is defined in wp-admin/includes/plugin.php so it’s only available within the admin unless I call it. I needed to add include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); so my final code was as shown below which I also tidied up a bit too. add_filter(‘wp_nav_menu_items’,’add_about_page_to_menu’, 10, 2); function add_about_page_to_menu( $items, $args ) { include_once( ABSPATH . … Read more