Update:
The custom link does not work in my case as I need the correct sub navigation to be displayed.
Situation
Parent A
— |_______Sub Nav A-1
—- |_______Sub Nav A-1-1
—- |_______Sub Nav A-1-2 … etc
— |_______Sub Nav A-2
—- |_______Sub Nav A-2-1
—- |_______Sub Nav A-2-2 … etc
Parent B
— |_______Sub Nav B-1
— |_______***Sub Nav A-2*** — Crosslink back to Parent A – SubNav A-2
Parent C
— |_______Sub Nav C-1
— |_______***Sub Nav C-2*** — Crosslink back to Parent A – 2 SubNav A-2
The current level navigation gets rendered correctly. In the above examples we assume there are 3 levels.
Within first sublevel (lvl 2 (A-1, A-2, B-1 etc) ) page we pull out the sub items to rendered a further submenu (lvl 3). In our case [ Sub Nav A-2-1, A-2-2 etc ]
Let’s call the page we want to get to Parent A => SubNav A-2 …. /parent-a/subnav-a-2
Sub navigation items within this structure are [A-2-1, A-2-2 etc ]
The problem occurs when you attempt to render Page Sub Nav A-2 and its sub navigation elements (lvl 3 navigation items list) – depending on ‘how’ you get to the page.
If you access the link via Parent B or Parent C the sub items have no children and therefore no sub navigation elements are found.
Option 1: Admin navigation select the page to link to by all sub nav items
-This fails. Either the first or last (based on widget config) is selected but this is not the case as sometimes the order of the page we need to get to is not first or last.
Option 2: Use the correct page relative to the page structure and link the other nav items with a variable (I used /?crosslink=1 )
-This fails as the navigation tree is picked up based on the full link, not the permalink/slug
Hopefully this makes sense. Any help or recommendations appreciated.
Basically IF a page is linked within the Navigation Plugin then that page has an ID of some sort. This ID can identify which branch in the navigation is the ‘correct’ branch.
An alternative could be to set some query parameter to fall back to the base URL (like my ?crosslink example which the plugin (or WP Nav) could filter by…
-
This reply was modified 7 years, 2 months ago by
wordpsam.
-
This reply was modified 7 years, 2 months ago by
wordpsam.
For anyone trying this I have found a workaround (that on initial testing works)
Using .htaccess you check for a specific query parameter and redirect to the base path URL removing the query parameters along the way.
It works in my case as the pages use a permalink structure without query parameters.
NOTE: this solution will not work for URLs with query parameters. (or can but the RewriteCondition needs reworking.
Step 1: Any cross linked page requires a custom link and an additions suffix
/path/path/?crosslink=1
Step 2: Modify the .htaccess
RewriteCond %{QUERY_STRING} .*crosslink.*
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}? [L,R=301]
This will allow you to cross link multiple pages (all with the custom link and crosslink query parameter) and leave the actual page with the correct URL.
Worked for me! Good luck.