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

Concatenate string to the_field()

You’ll have to show more of the relevant code, but, to begin with, if you want to check for the availability of a ‘preparation_time’ ACF value, use if ( get_field( ‘preparation_time’ ) ) : // get_field(), not the_field() As the ACF docs put it, the_field( ‘field’ ) is the same as echo get_field( ‘field’ ) … Read more

Highlight the links without using dropdown

SOLUTION I found it by using the <?php wp_list_pages( $args ); ?> with customizing the args to display only selected children by id. $args = array ( ‘title_li’ => ”, ‘child_of’ => $post->ID, ‘include’ => 47 ) <h4> <?php wp_list_pages( $args ); ?> </h4> and setting the css to target the current and its parent … Read more

Adding function to child theme’s function.php

You can’t recall the same function or PHP will throw an error. Make your own function and call the same action hook, but give it a priority of 1 which should overrule the parent theme function. function custom_oblique_post_link_to_single() { if ( ! get_theme_mod( ‘read_more’ ) ) :?> <a href=”https://wordpress.stackexchange.com/questions/282703/<?php the_permalink(); ?>”> <div class=”read-more”> <?php echo … Read more

Refactoring long if/else php chains

There is no hard limit, but when you have many fields (I’m talking hundreds or thousands, not dozens), you might run into limits on execution time on your host. In this case, I’d do something like this to turn it into a loop if you don’t need specific HTML. foreach(range(1, 5, 1) as $imageNumber) { … Read more