Wordpress rewrite url /item1 to /about-us/item1 - wordpress

I have a situation where I need some custom routes in my Wordpress set up.
In my menu, there is an 'about us' item (which I set as a custom link) but it is not clickable, and just has 2 sub items in a drop down. The 2 sub items, are pages that do not have a parent page.
So when I click on either of those sub items i get this for example. www.example.com/item1 but I want it to be like this www.example.com/about-us/item1
I've made the 'about us' item as a custom link in the Wordpress menu builder with no actual link because the client wants that as the header item with those 2 children, but doesn't want a standard 'about us' page so it does screw up the urls.
Is there a function I can use to rewrite the urls, and will the default search give me the new urls back as the permalink if they ar found in the search results?
I guess I could create an 'about-us' page, but not do anything with it except using it for hierarchy purposes but it seems a bit messy to do that, plus I don't want the risk of it showing up in search results at all.

You have to create the child page with those sub pages and then use custom links for your entire About Us nav section with dropdowns. There is no other way to do this unfortunately.

Related

Assigning Child Pages to Non Existent Parent Pages in WordPress

I'm surprised that after searching for so long I couldn't find any solution to my problem and so I thought of posting it here :)
So we can create 'pages' in WordPress and drag and drop them under 'menus' as we like to create a parent-child relationship. But what if we have a non-existent page using a custom link such as '#', how can we assign a child page to that particular parent page that doesn't exist?
So I have 'Parent 1' that has been added as a custom link under menus and the url is basically '#'. Obviously, that won't be registered as a parent page because it's a custom url but I don't need to add it as a parent page, it's more of a reference in the top menu. The main reason I'd want to do this is to make use of breadcrumbs. Thoughts?
Without messing with rewrite rules or custom slugs, why not just create a blank page and set the hierarchical relationship the normal way.
On the Menu you can still use the Custom Link # item and place the children accordingly. You can even name the blank page "Parent (Intentionally Left Blank)" so it's less confusing in the admin.
This would also allow you to have the appropriate hierarchical structure in your admin when you view the All Pages admin page that looks like:
Parent (Blank)
Child 1
Child 2

URL submenu if primary menu is custom link wordpress

this is my situation in a wordpress menu :
Example 3 is a custom link, so the URL of submenu is
www.site.com/sub1 and not www.site.com/example3/sub1
www.site.com/sub2 and not www.site.com/example3/sub2
How to do?
let me just post the answer here. Check out my demo site
http://dev.blurbpad.com/21sthomeloans/
Then hover over About Us in the Menu, you will see two sub pages. Open both in separate tabs. I think what you want to happen is what I did in subpage 1 where it's not showing in the url the-company (like in sub page 2)
The only time it will say that in the URL is if you made the another page a parent of the sub page (in this case "about us"). If you just make the adjustments in appearance>menus in wordpress, and not make it a child of another page, then the URL will not be affected.

Put categories on PAGE url wordpress

Ok, here is the thing I have already added the categories to the pages (with the help of a plug-in, it's called Add category to pages) and so now I want to change the URL to display the categories (that is to say I want my pages to have this estructure: mysite.com/%categories%/%page_name% right now it has his structure: mysite.com/%page_name%), I have tried to google it but I can't find a straight answer. So if anyone has some resources (tutorials, articles) or some idea (if it's not to much to ask with code examples) on how to achieve this it would be fantastic. (And believe me, I'm asking as my last resource)
you can do it easily with "Page Parent" option available in WordPress.
Steps To create a subpage
Go to Administration > Pages > Add New screen.
In the right menu, click the “Page Parent/No Parent” drop-down/page attribute widget. The drop-down menu contains a list of all the Pages already created for your website.
Select the appropriate parent page from the drop-down menu to make the current Page a child Page.
Add content to the subpage.
Click Publish when ready.
Output - https://example.com/asia/india/
More Info. - Wordpress Subpage Permalink
well you can do this for categories and products from permalink setting, but if you want to manipulate the page url according to yourself then you need to create an blank page with the prescribed name whichever you want to insert, i.e, if you want to insert amazon within the url then create an url with name of amazon, and put the other url's under this parent page.
This way your url will look like
http://example.com/amazon/page_name
Unable to post as comment so directly posting it in an answer, in WordPress you can have custom URL. After you logged I'm as admin under dashboard you have general settings where you can put custom URL's like http://example.com/%caregory%/page_name
For more reference also checkhttp://codex.wordpress.org/Changing_The_Site_URL
I don't know if you tried this but after you login as admin, under Dashboard>>Settings>>Permalinks>>Custom Structure.
Let me know if you have already tried that.

posts as children of wp_list_pages item

i have a vertical menu that looks like this
HOME
NEWS
ANOTHER PAGE
- SUB PAGE
- SUB PAGE
it is retrieved via wp_list_pages. NEWS is set as my posts page in the WP backend.
what i want to achieve is getting the titles of the 3 latest posts to show up as a submenu of NEWS like so:
HOME
NEWS
- POST 3
- POST 2
- POST 1
ANOTHER PAGE
- SUB PAGE
- SUB PAGE
is there some sort of add_filter/function or even plugin to achieve this?
The problem looks as if you're trying to use a Page Object as a sort of "shell" for corresponding posts. This is probably one of the first traps a Wordpress Developer will find themselves in when developing their own themes, or working with existing code.
In short, you shouldn't use wp_list_pages if you're trying to also list Post Objects. It gets messy, and you're essentially circumventing existing methods that Wordpress provides to do exactly what you need.
What you'll want to do is look into is the built-in Navigation Menus to build out a more flexible menu. If you're using a downloaded theme, then it will almost certainly be supported. Otherwise, you'll need to look into Registering a Navigation Menu to make your theme "menu-aware".
What this will enable you to do is build a flexible menu that supports not only Pages, but also Categories and individual Posts in an intuitive UI. I would suggest deleting that Page Object called "News" altogether, and instead place the News Category in your menu alongside all of your Page Objects in whatever order you like.
As for querying the most recent three posts in your Navigation Menu as sub-menus, this will be a little more complicated to do with pure code.
What I would suggest is to look into this option first. Build out a working - albeit static - prototype to get a feel for the Menu Interface. If you're writing your own theme, replace your wp_list_pages call altogether with wp_nav_menu.
Once you get that working, open a new question to see how to write your own Nav Menu Walker to make everything display exactly how you want.
By taking this approach, you'll ensure that your theme will ALWAYS behave how you want automatically, rather than having to go in every so often to patch things up.
Let me know if this helps.

WordPress 3 - Problem with menu highlighting

I'm building a site that has a two level menu created with the admin Menu tool. The menu contains links to both Pages and Category lists. It doesn't link directly to Posts. The problem is that when you drill down into a Category list and click to view a single post in that Category, the menu highlighting gets it wrong.
I've tested on a new install of WP3, set up a simple test site with a few pages and posts in 3 categories. All I've changed in the theme is the style.css to highlight the whole path.
http://danwashere.com/wp_dev/
Here's a direct link to view a categorised post here:
http://danwashere.com/wp_dev/2011/07/28/blue-rocks/
Everything is a page, except with the section "Advice Categories" - all those sub items are category lists containing categorised posts - each post is only categorised with a single category. The menu structure is defined entirely in the Menu settings.
On that Blue Rocks page, the menu should be highlighted like this: Advice Categories -> Rocks, but it's highlighting the Sample Page item. And if you rollover the "Advice Categories" menu, you'll see that it is correctly highlighting the "Rocks" menu item.
It seems to me that WP is applying the 'current-post-parent' class to the wrong top menu item, but maybe I'm missing something?
// Edit, rewrite to make it clearer.
It seems as though were both having very similar issues. - Trouble highlighting correct menu parent with wp_nav_menu classes while viewing “single posts”
Im not using categories as links in my menu but I use them to filter content to each page via query_posts...if you examine the output from Wordpress you'll notice its actually placing the current page class onto the incorrect li tag when viewing a single post - Is this happening to you as well?

Resources