How to register a menu based on a ACF condition

Ok, so the problem was that I was adding the variable outside the function. After some cleanup, code looks like this and it works! function roots_setup() { // Variables $header_type = get_field(‘header_type’,’options’); if (($header_type)==’brand-centered’) { register_nav_menus(array( ‘brand_centered_left’ => __(‘Brand Centered Navigation (Left)’, ‘roots’) )); register_nav_menus(array( ‘brand_centered_right’ => __(‘Brand Centered Navigation (Right)’, ‘roots’) )); } else … Read more

wp_nav_menu work in functions.php but not in the theme

I had a pre_get_posts. What I missed was this: && $wp_query->is_main_query() This prevents the pre_get_posts to run on the menu query. Full code add_action(“pre_get_posts”, “custom_front_page”); function custom_front_page( $wp_query ){ if( is_admin() ) { return; } if( is_front_page() && $wp_query->is_main_query() ) { $wp_query->set(‘post_type’, ‘produkt’); $wp_query->set(‘page_id’, ”); $wp_query->is_page = 0; $wp_query->is_singular = 0; $wp_query->is_post_type_archive = 1; $wp_query->is_archive … Read more

Showing user profile data on front-end

You are trying to access the meta data of the user with ID stored in $user->ID but the object $user is not defined in your code. You are also using an undefined variable $user_ID. The quickest fix in your code would be to change this: get_the_author_meta( ‘province’, $user->ID ) ) With: get_the_author_meta( ‘province’, $userdata->ID ) … Read more

How do I register a new settings page? [closed]

you can try a code like this <?php function theme_settings_init(){ register_setting( ‘theme_settings’, ‘theme_settings’ ); } î This is used to reserve a name for a custom settings array //Add settings to page menu function add_settings_page() { add_menu_page( __( ‘Contenu éditable’ ), __( ‘Contenu éditable’ ), ‘manage_options’, ‘settings’, ‘theme_settings_page’); } î This will create the page … Read more

video.js not enqueueing?

It could be a couple of things: video.js doesn’t exist at get_template_directory_uri().’/js/video.js’ WP isn’t recognizing modernizr as a registered script, so it won’t enqueue video-js A couple of things to try/research: Is there any plugin already registering a script named modernizr and/or video-js? Try registering (not enqueueing) modernizr within your lw_scripts_10 like so: function lw_scripts_10() … Read more

Getting out side of wp root folder from function.php using absolute path

If you want the absolute path to your theme’s stylesheet directory you could use get_stylesheet_directory(). If you want the URI of your theme’s stylesheet directory you could use get_stylesheet_directory_uri(). get_theme_root() will return the absolute path to the themes directory. get_home_path() will return the absolute filesystem path to the root of the WordPress installation. Once you’ve … Read more