Progmatically adding menu links to the default (Top) or Footer menu

You have to register the menu location first. Also, I’ve added else statement to be sure $menu_id is defined when menu exists. Otherwise, you’ll see the PHP Notice about undefined variable. WP_DEBUG must be turned on when you develop, that’s why you don’t see the notice. // Initialize name and location $menu_name=”Simple Inventory Menu”; $menu_location … Read more

How to add “get_theme_mod” inside a shortcode?

I would comment, but lack the pointage… You seem to be on the right track: I see that your shortcode callback and the function are named differently: (f_gallery_shortcode / function_gallery_shortcode). Try this: add_shortcode( ‘ui_gallery’,’function_gallery_shortcode’ ); function function_gallery_shortcode(){ $dynamic_h1 = “<h1>” . get_theme_mod(‘dynamich1’) . “</h1>”; return $dynamic_h1; } now using [ui_gallery] in your posts, should return … Read more

get_theme_mod filter ignores sanitize_callback

Sanitization via the sanitize_callback function takes place when you save the the theme mod. Retrieving a theme mod via get_theme_mod() (which runs the theme_mod_{$name} filter) does not use the sanitize_callback function. So, whatever you’ve set $_GET[‘header_layout’] to will be used regardless of whether it is valid or not. From wp-includes\theme.php: /** * Retrieve theme modification … Read more

get_theme_mod only returns false

The debugger tells me that get_theme_mod() is returning ‘false’, when I expect it to return the value of the selected item. get_theme_mod() isn’t working because when you registered the setting, you set the type to option: $wp_customize->add_setting(‘title_font’, array( ‘default’ => ‘Roboto Slab’, ‘capability’ => ‘edit_theme_options’, ‘type’ => ‘option’, ‘transport’ => ‘postMessage’ )); The possible values … Read more

Return a numerical function value in Customizer controls

The solution for me ended up being to simply remove the np_post_num() add_action hook altogether, and instead declare get_theme_mod() as the desired variable $option_pg_number. This allowed use of the returned number variable in a separate loop function controlled by $option_pg_number, instead of just printing the returned number value of ‘np_posts_per_page’ on the page. $option_pg_number = … Read more

Update Theme Location Programatically

Generally speaking, you shouldn’t be (or need to be) “updating” the theme_location for a custom nav menu. The theme_location is the template location for a given nav menu. If you need to do dynamic manipulation of a custom nav menu, you might be better off targeting the id of the menu, rather than the theme_location. … Read more

Loop get_theme_mod

There is get_them_mods() which will… Retrieve all theme modification values for the current theme. If no theme mods have been set, will return boolean false. https://codex.wordpress.org/Function_Reference/get_theme_mods It should return an array that you can loop over.

adding checkbox to theme customizer

I was able to solve this. Here is the code that got the checkbox working. function theme_customizer_register_checkbox($wp_customize) { $wp_customize->add_section( ‘global_options’, array( ‘title’ => ‘Global Options’, ) ); $wp_customize->add_setting( ‘show_supporters’, array( ‘default’ => true, ‘transport’ => ‘postMessage’ ) ); $wp_customize->add_control( ‘show_supporters’, array( ‘section’ => ‘global_options’, ‘label’ => ‘Show supporters section?’, ‘type’ => ‘checkbox’ ) ); } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)