WordPress custom menu can't show 3. level submenu

I Use a custom walker from my menu in WordPress and my menu doesn't show all levels. https://soulofcroatia.com/ ->One Day menu item. This is my code in header.php <?php wp_nav_menu( array( 'theme_location' => 'mainmenu', 'menu' => 'mainmenu', 'container' => 'ul', 'container_class' => 'collapse navbar-collapse', 'container_id' => 'navbarCollapse', 'menu_class' => 'nav-list', 'echo' => true, 'fallback_cb' => 'wp_page_menu', 'items_wrap' => '<ul class="%2$s">%3$s</ul>', 'depth' => 3, 'walker' => new Primary_navigation_walker(), ) ); ?> this is my code in custom-walkers.php class Primary_navigation_walker extends Walker_Nav_Menu …
Category: Web

It is possible to pass $args that sent by add_settings_field() inside another function?

I'm trying To do my plugin Setting with OOP PHP when I'm Creating Setting Filed it sends $args so I can use it in their function, but when I call this function in another place it is for $args and it's undefined. here are my codes: Please Look At the Last Chapter and see the $args Add Setting: add_settings_field( 'st-test-color', __('Color', 'st-search'), 'st_color_ca', 'st-test', 'st-test-settings-section-2', array( 'name' => 'color_css', 'id' => 'st-test-color', 'class' => 'st-test-color', 'options' => $st_test, ) ); …
Category: Web

Is it possible to save more than one image to an option?

The following code allows you to upload multiple images but only one is saved to the option. Can multiple images be saved to the option as an array or would I have to create separate controls? $wp_customize->add_section("slider",array( 'title'=>"Slider", 'description'=>"Choose the images for the slider", 'priority'=>'36' )); //images $wp_customize->add_setting("slider[images]",array( 'default'=>"", 'type'=>"option" )); $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize,"slider[images]",array( 'label'=>__("Images","adaptive-framework"), 'section'=>"slider", 'settings'=>"slider[images]" )));
Category: Web

Change CSS Variable value in Theme Customizer Live Preview

I am trying to change a CSS Variable value in customizer and couldn't get live preview working using 'postMessage'. It works if I use 'refresh' option. Can someone please have a look at the code and point me to the right direction. Thanks. customizer.php code /** * Registers settings and controls with the Customizer. * * @param WP_Customize_Manager $wp_customize Customizer object. */ function mytheme_customize_register( $wp_customize ) { $wp_customize->add_setting( 'primary_color', [ 'default' => '#b3000e', 'sanitize_callback' => 'sanitize_hex_color', 'transport' => 'postMessage', ] …
Category: Web

Dynamically switch file in get_template_directory_uri() | Function

I need to switch scheme color of my WordPress theme trough Redux option panel. My plan is switch the CSS file trough get_template_directory_uri() | Function. The scenario is: Create 2 scheme color: dark and light with dark.css and libght.css. Control from redux panel with this code: <?php Redux::setSection( $opt_name, array( 'title' => __( 'Color Scheme', 'javapaper' ), 'id' => 'test_scheme', 'icon' => 'el el-list', 'fields' => array( array( 'id' => 'color_scheme', 'type' => 'image_select', 'title' => __( 'SELECT Color Scheme', …
Category: Web

Add Plugin options as subpage to Theme options page

I have my own Theme with an options page. Now I am developing a new Plugin which should have an options page that should be a subpage of the Theme options page. Theme options.php: <?php function xx_theme_admin_menu() { add_menu_page( 'Theme Settings', 'Theme Settings', 'manage_options', 'xx-settings', 'xx_theme_admin_page' , '/wp-content/themes/xx/assets/img/logo-Grayscale-30x25.png' ); } add_action( 'admin_menu', 'xx_theme_admin_menu' ); function xx_theme_admin_page() { ... } Plugin options.php: <?php function xx_cookie_banner_admin_menu() { add_submenu_page( 'xx-settings', 'Cookie Banner', 'Cookie Banner', 'manage_options', 'xx-cookie-banner', 'xx_cookie_banner_admin_page' ); } add_action( 'admin_menu', 'xx_cookie_banner_admin_menu' ); …
Category: Web

Theme option page doesn't save options

I am trying to practice adding theme options page using settings API but unfortunately the code i have written according to the codex doesn't work properly. When i tested the code no errors generated but the pe_bannar_heading option can't be saveed , So would you please help me find where the problem is in the following code <?php /* Plugin Name: Test option page Text Domain: test-option-page */ function reg_settings(){ register_setting('pe_theme_options','pe_theme_options'); add_settings_section('pe_main_settings','Main Settings', '', __FILE__); add_settings_field('pe_bannar_heading', 'Bannar Heading:', 'pe_bannar_heading_setting', __FILE__, …
Category: Web

Gallery functionality in custom theme

I'm new to creating my own theme and I barely scratched the surface of this topic so far. But my end goal would be to create a "gallery like" functionality. Maybe there are some functions or prebuild things in WP that could help me out here before I do all of this from scratch. Some terms what I can google for or look in the documentation would help me out a lot. Because when I search for stuff on google …
Category: Web

How to escape custom css?

I'm creating a WordPress theme in which I've allowed users to add some custom css from the Theme Options. This css code then directly gets echoed out in the head section of the page, with the following code: add_action('wp_head', 'theme_dynamic_css'); function theme_dynamic_css(){ global $my_theme_options; $custom_css = ''; if (isset($my_theme_options['custom-css'])) { $custom_css .= $my_theme_options['custom-css']."\r\n"; } echo '<style id="my-theme-custom-css">'.$custom_css.'</style>'; } Should I be using esc_html(); here? At first I assumed if the code is between the style tags, then it shouldn't be …
Category: Web

Shortcode or placeholder for theme options page?

I'm writing a theme options page that provides a space for the user to enter code for social buttons e.g. <a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo get_permalink(); ?>">Tweet</a> Obviously, having <?php echo get_permalink(); ?> for the data-url attribute is not going to work in a theme options textarea. What are my options here? I've seen others user shortcodes e.g. [permalink] - but how can I process the shortcode? placeholders e.g. {{url}} - again, how do I replace these placeholders? Appreciate any …
Category: Web

Additional custom header image

Has anyone seen a way to add a new header_image to a theme? I need to add two configurable images in a theme. It doesn't really matter if it gets added as a new "Header" admin theme menu or if it's added to the existing Apperance->Header menu. I'm a bit new to plugin development so any help in the right direction is appreciated. I can't really find any hooks or actions to attach to. Similar to this request
Category: Web

Show multiple option in URL with Redux framework in front end

I'm creating a WordPress theme in which I'm using the Redux Framework for creating the theme's options page. I want to show multiple blog layouts without creating custom WP templates. I saw in many themes the URL is something like theme.com?home_layout=grid&sidebar=left theme.com?home_layout=list&sidebar=none Now in the theme-option file i've got this one for the sidebar: array( 'id' => 'sidebar_position', 'type' => 'select', 'title' => esc_html__( 'Blog sidebar', 'omio' ), 'options' => array( 'left' => esc_html__('Left', 'omio'), 'right' => esc_html__('Right', 'omio'), 'disable' …
Category: Web

Count when a post of a custom post type is deleted and store it in a theme option

I work on a website that shows products in a catalogue without checkout. Those products can be bougth stationary, and then the product will be deleted from a custom post type. So, I basically want to count all deleted posts of a certain post type, add them to a theme option value, and then update the theme option value with the new value. I thought of something like this: function getSoldProductsCount() { $addCount = 0; $oldCount = get_option( 'sold_products_count', 'number' …
Category: Web

Using jQuery to retrieve customizer value

I am trying to use jQuery to retrieve a theme options (customizer) value: $wp_customize->add_setting( 'header_fixed', array( 'default' => true, ) ); $wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'header_fixed', array( 'label' => __( 'Enable fixed navigation?', 'theme' ), 'section' => 'header_section', 'settings' => 'header_fixed', 'type' => 'checkbox', 'priority' => 40, ) ) ); If the above value is true, then the header element will be fixed position. If not, it will be relative position (a class will be added, or not, with jQuery). …
Category: Web

Illegal string offset in PHP function in via Theme Customizer

I have this setting in wp_customize: // Select share box options. $wp_customize->add_setting( 'single_share_box_options', array( 'default' => $this->defaults['single_share_box_options'], 'transport' => 'refresh', 'sanitize_callback' => 'quanticthemes_text_sanitization', 'active_callback' => 'quanticthemes_share_box_condition', ) ); $wp_customize->add_control( new Customizer_Simple_Checkbox_Control( $wp_customize, 'single_share_box_options', array( 'label' => __( 'Share Box Options', 'custom' ), 'description' => esc_html__( 'Select share box options.', 'custom' ), 'section' => 'single_post_general_section', 'active_callback' => 'quanticthemes_share_box_condition', 'input_attrs' => array( 'sortable' => false, 'fullwidth' => true, ), 'choices' => array( 'facebook' => esc_html__('Facebook', 'custom'), 'twitter' => esc_html__('Twitter', 'custom'), 'linkedin' => …
Category: Web

display category name based on its equivalent id

I have a theme with options. I would like to display 3 posts for a specific woocommerce category, I could show category id and I don't know how to display products based on its category id, but I have code snippet it shows products by woocommerce category name. So I need now to a selected category name not its id, or to convert it from category id to category name? I tried following but it did not work at all. …
Category: Web

Using theme options to change link colours

I'm developing a WordPress theme with some theme options (using the ThemeShaper sample theme options page), and one of the options I want is to allow users to set their own link colours. At the moment I can get the hex value they set (say #134679 or something) and spit it out somewhere, but I don't know how to include it in the theme. Presumably it needs to be dynamically added to a stylesheet (or a new stylesheet dynamically generated?) …
Category: Web

Defining path of content folder in WP-config solves the issue of missing header, footer, theme options. Is this a good approach? Expert Advice needed

The header, footer, theme options went missing on the website. I am using the latest Bitnami WordPress Stack on Amazon Lightsail, Approach A: Bitnami installations using system packages. When I migrated my website to this new server, the header, footer, theme options went missing on the website. But doing the below solves the issue. I am not sure if this is the right thing do? or does it affect anything. If anyone has more knowledge about this, please let me …
Category: Web

Javascript File Does Not Work

I created a page independent from the theme and added the php and js files of the pageto the theme folder, the php file works but the js file does not. Why could it be? PHP File: <?php if (!is_user_logged_in()) { wp_redirect(esc_url(site_url('/'))); exit; } else{ get_header(); get_sidebar( 'left' ); ?> <div id="primary" class="content-area region__col region__col--2"> <main id="main" class="site-main"> <div class="create-prediction"> <h2 class="headline headline--medium">Guess Now</h2> <input class="new-prediction-title" placeholder="Title"> <textarea class="new-prediction-body" placeholder="Your guess here..."></textarea> <span class="submit-prediction">Guess</span> </div> <ul class="min-list link-list" id="prediction"> <?php …
Category: Web

How do I have my widgets in a Sidebar for my http://localhost/wordpress/

I have installed wordpress version 5.7.1 with MAMP 6.3 on my MacOS laptop. However on localhost/wordpress, I do not like the way the Twenty Twenty-one theme is set out because under appearance, I had to create a a customised widget, which included a Meta Widget for a Log in. The problem is that I have to scroll down the page to find the Log in as can be seen below. How do I have all these Widgets (Search bar, Meta, …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.