How to get correct URLs in network wide menu (Multisite)?

I'm using this function to switch to my main website's navigation and display it on all sub sites in my multisite network. Ideally the links should have the following format: http://www.mysite.com/navigation-link but on the sub-sites the urls are http://www.mysite.com/subsite/navigation-link Obviously these pages don't exist so it's just showing a blank page. Any idea how I could make sure the urls are like the first example and how I might incorporate that into my function? function wp_multisite_nav_menu() { global $blog_id; $args …
Category: Web

Customize menu link for taxonomy in WP menu

I have a Taxonomy that I would like to change the link to in the WP menu. When clicking it goes to the Add Taxonomy page, like normal. What I would like to do is navigate to the Edit Page. In other words, the taxonomy navigates to edit-tags.php (as expected) /wp-admin/edit-tags.php?taxonomy=news_archive_options&post_type=news What I'd like to do is navigate to the term.php page /wp-admin/term.php?taxonomy=news_archive_options&tag_ID=10&post_type=news Thanks!
Category: Web

Bookmark anchor link to load another page first before completing?

Question: is there a way for a link to an anchor bookmark to arrive at its destination by loading another page first? I'm developing a vertical-scrolling style website where the home page displays the contents of 3 other pages within sections or divs. Each section has a bookmark and a "back to top" link, and my main navigation menu uses custom bookmark anchor links. I'm also using thejQuery smooth scrolling plugin which works very well. The problem I'd like to …
Category: Web

WordPress navigation wont appear with wp_head

so im building a custom theme and ive got stuck on the navigation if i use wp_head(); it loads bootstrap and my custom style sheet but not the navigation if i use get_header(); it loads the navigation but not bootstrap or my custom style sheet here is my functions.php function register_navwalker(){ require_once get_template_directory() . '/inc/class-wp-bootstrap-navwalker.php'; } add_action( 'after_setup_theme', 'register_navwalker' ); function wpbootstrap_enqueue_styles() { wp_enqueue_style( 'bootstrap', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css' ); wp_enqueue_style( 'my-style', get_template_directory_uri() . '/style.css'); wp_enqueue_script('bootstrap-js', 'https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js', array('jquery'), NULL, true); } add_action('wp_enqueue_scripts', 'wpbootstrap_enqueue_styles'); …
Category: Web

Wordpress change wp_nav_menu walker with a custom one

I have a downloaded theme and it where the wp_nav_menu is created it looks something like this: <div class="nv-nav-wrap"> <div role="navigation" class="<?php echo esc_attr( join( ' ', $container_classes ) ); ?>" aria-label="<?php esc_attr_e( 'Primary Menu', 'neve' ); ?>"> <?php echo wp_nav_menu( [ 'theme_location' => 'primary', 'menu_id' => $menu_id, 'menu_class' => 'primary-menu-ul nav-ul' . $additional_menu_class, 'container' => 'ul', 'walker' => '\Neve\Views\Nav_Walker', 'fallback_cb' => '\Neve\Views\Nav_Walker::fallback', 'echo' => false, ] ); ?> </div> </div> I've created a child theme and I want to …
Category: Web

How to display dynamic content in start_lvl function

I am creating a custom nav walker but having trouble outputting parent menu item title in start_lvl function. I want to output it right after the <div class="dropdown"> in the following start_lvl function. function start_lvl(&$output, $depth = 0, $args = array()) { $indent = str_repeat("\t", $depth); if ($depth == 0) { $out_div = ' <div class="dropdown-wrapper"><div class="dropdown">This is where I want to output parent item title'; } else { $out_div = ''; } // build html $output.= "\n" . $indent …
Category: Web

wp_nav_menu doesn't seem to work on custom post type pages

I'm working on something someone else set up, and on the index page, the nav appears, but on custom post type pages, it does not. The nav menu: wp_nav_menu([ 'menu' => 'Primary Menu', 'theme_location' => 'primary', 'depth' => 3, 'container' => 'div', 'container_class' => 'a', 'container_id' => 'b', 'menu_class' => 'nav navbar-nav', 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'walker' => new wp_bootstrap_navwalker() ]); I've seen it suggested that I place this in a function and use an if statement to do something and …
Category: Web

Additional navigation bar in header

Recently, my site started showing two navigation bars at the top of my page. They are also the wrong layout. I am fairly new to WordPress. I have only designed five websites so far. This is the first time I have encountered this issue. I am editing through Elementor Pro, and this does not show up when I preview the page, but it shows up when you enter into the website itself. How can this be fixed?
Category: Web

Post in multiple categories do not include in previous / next post if one category in excluded

I have read the following post which appears to solve my problem but doesn't... excluded_categories parameter in next_post_link() behaving unexpectedly I have posts in say 3 categories but if they are included in category 'update' (which is ID 96) I would like them excluded from the previous / next navigation system. From the above post I have edited the following code (this is all in my functions.php file as the single.php template calls for the navigation from there). <?php previous_post_link( …
Category: Web

wp_nav_menu() doesn't work

I'm working on a theme with custom menus, currently using WP 4.0.1. I'm registering two menus in functions.php: register_nav_menus( array( 'primary' => __( 'Main Menu', 'wsy' ), 'secondary' => __( 'Secondary Menu', 'wsy' ) ) ); Then, displaying them in my header.php file: <nav role="navigation"> <?php wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => '1' ) ); ?> </nav> The problem is, when I select a specific menu from either the Menus page or the customizer, they stop showing up in …
Category: Web

How to remove anchor of current menu item in navbar?

Wordpress nav menu created by wp_nav_menu can highlight current menu item. How can i strip anchor from current menu item? For example, we have menu: <ul> <li class="current-menu-item"><a href="/somelink">Home</a></li> <li><a href="/elselink">Item</a></li> ... </ul> Can we remove <a href="/somelink"> and leave just "Home" if it is current page? UPD. In my functions.php I have a walker like this: class My_Walker_Nav_Menu extends Walker_Nav_Menu { function start_lvl(&$output, $depth) { $indent = str_repeat("\t", $depth); $output .= "\n$indent<ul class=\"dropdown-menu\">\n"; } } and I've found the …
Category: Web

How can I click the parent menu then redirect to a special URL?

You see I have a Navigation bar items, in the parent item Products & Services with two sub menus. I have a requirement, when I click the menu item Products & Services it redirect to its sub-menu Dedicated Servers. How can I do with this? EDIT-01 I only want the Products & Services parent have this redirect, the other parent do not need, such as Home, Advantage they all have their own page.
Category: Web

How do I structure my permalinks in Wordpress?

I am using wordpress and all I want to do is make the URL appear in the form where, Blogs is mentioned and then the blogname. But I want this structure only when someone visits blogs page. The blogs slug shouldn't appear elsewhere like if i go another page, then the blogs shouldn't be shown. The structure I am desiring should only appear when someone is accessing blogs pages. For Ex: www.example.com/blogs/blogname - That's it! NO CATEGORY, NO NOTHING. ONLY …
Category: Web

wp_nav_menu not selecting teh correct menu

I'm having a weird issue. I have 2 menus, and registered them in functions.php, like this: add_theme_support( 'menus' ); register_nav_menu( 'primary', 'Top Nav' ); register_nav_menu( 'footer', 'Footer' ); In my header, I have the following code <?php wp_nav_menu(array( 'menu' => 'Top Nav', 'theme_location' => 'primary', 'depth' => 2, 'container' => 'div', 'container_class' => 'navbar-collapse collapse', 'menu_class' => 'nav navbar-nav navbar-right', 'fallback_cb' => 'wp_bootstrap_navwalker::fallback', 'walker' => new wp_bootstrap_navwalker() )); ?> However, the header always display the other menu, assigned to footer, …
Category: Web

How to get next post link of child custom post type from parent post and get next post link of parent post from the last child post?

I have a custom post type with this structure: First Parent 1st child of First Parent 2ndchild of First Parent 3rd child of First Parent Second Parent 1st child of Second Parent 2nd child of Second Parent 3rd child of Second Parent I'm trying to make previous_post_link() and next_post_link() to work that when you are in the First Parent, the next_post_link() will go to the 1st child of First Parent and then when you are in the 1st child of …
Category: Web

How make get_next_post() return first post when viewing last one

I need a way to link to the first and the last post (CPT) created. For example, I'm in the last post and if I click in "next" I should go to the first. Now i have this <?php $next_post = get_next_post(); if ( ! empty( $next_post ) ) : ?> <div id="nextpost" > <a href="<?php echo get_permalink( $next_post->ID ); ?>"> <!-- <?php echo get_the_post_thumbnail( $next_post->ID, 'thumbnail' ); ?> --> </a> <span class="nav-next"> <?php next_post_link( '%link', __( 'Next project', 'twentyeleven' …
Category: Web

Override the WordPress default pagination markup

I want to render the WordPress posts pagination markup with my own HTML markup. My theme has a pagination markup with ul > li format. But the WordPress default pagination markup is different than my markup. How can I apply my own HTML markup instead of the default pagination markup?
Category: Web

About

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