Widgets not showing on custom theme

Try to combine both sidebars/arrays into one function. function my_widgets() { register_sidebar( array( ‘id’ => ‘contact-info’, // add the rest here ), register_sidebar( array( ‘id’ => ‘social-links’, // add the rest here )) ); } add_action(‘widgets_init’, ‘my_widgets’); Then you call the deisred sidebar <?php if(is_active_sidebar(‘contact-info’)) : ?> <?php dynamic_sidebar(‘contact-info’); ?> <?php endif; ?>

Accessing values from ACF sub field (flexible content area) in PHP

You iterate through posts obtained by the get_posts(), so you have to pass post ID as the second parameter of the function have_rows(). By default ID of current post is used. foreach ($articles as $article) { $value = null; if( have_rows( ‘info_items’, $article->ID ) ): while( have_rows( ‘info_items’, $article->ID ) ): the_row(); $value = get_sub_field(‘info_location’); … Read more

How to make function appear in sentence?

You can use below code to display theme detail sentence. I have use wp_footer action,You can change hook as per your requirement. function logbook_info() { $theme_logbook = wp_get_theme(); $theme_name = esc_html( $theme_logbook->get( ‘Name’ ) ); $theme_uri = esc_html( $theme_logbook->get( ‘ThemeURI’ ) ); $theme_author = esc_html( $theme_logbook->get( ‘Author’ ) ); $theme_author_uri = esc_html( $theme_logbook->get( ‘AuthorURI’ ) … Read more

Please show me how to use an if/else statement in combination with wp_enqueue

I think something like the following should work. Uncomment the var_dump to double check you’re getting the saved theme mod value you’re expecting. If not, check the naming of your customizer setting and that it saved properly. function mytheme_styles() { $theme_dir_uri = get_template_directory_uri(); // enqueue common styles and scripts // wp_enqueue_style( $handle, $src = false, … Read more

class ‘wphpc_PAnD’ not found

It is usually caused by a filter or an action not properly declared. Somewhere in your theme or plugins is a line like: add_filter( ‘hook_name’ , array( ‘wphpc_PAnD’, ‘someMethod’ ) ); // or add_action( ‘hook_name’ , array( ‘wphpc_PAnD’, ‘methodName’ ) ); which register class method with hook for a action or filter, but this class … Read more

Do I always need to call wp_get_current_user() before accessing $current_user?

Yes, as a best practice, you should call wp_current_user() because you can’t assume that $current_user is set (or if it is set correctly with the user you’re after). Of course, there’s a third option that’s only just sprung to mind… test whether $current_user is already set/defined and if it isn’t, call wp_get_current_user(). Actually, that’s kind … Read more

Add value to new attribute inside WordPress menu items

I already had this need, I found this code somewhere in the web. up to you to customize it with your needs. I tested it on the Twenty Nineteen theme: Put this in functions.php : class themeslug_walker_nav_menu extends Walker_Nav_Menu { // add classes to ul sub-menus function start_lvl(&$output, $depth) { // depth dependent classes $indent … Read more