Customizing my account page in woocommerce wordpress - wordpress

When I customize the my account page in woocommerce, I can edit right side section by creating my_account.php inside my account folder in woocommerce. But In left side it is showing "Define your 'My Account' navigation Apperance > Menus",
After seeing this I tried to create menu called "My account", but there was no theme location existing, so I create a theme location called "my account menu". And I assign "my account" menu with theme location "my account menu".
I don't know how to connect this menu to my account page in woocommerce, the page again showing same "Define your 'My Account' navigation Apperance > Menus".

Try Appearance>Menus>Custom Links
Otherwise:
Is the theme you are trying to edit a pre-built theme?
Is the platform up-to-date or outdated (sometimes updates/bugs can alter functionality of pre existing code)?
Sometimes there are errors in the theme build, as I have seen. In such a case, I would recommend reaching out to the theme developer(s) as they can usually help the best in this situation. If not, check back. Hope this helps.

Call menu by menu name instead of theme_location
<?php wp_nav_menu( array( 'menu' => 'Main Menu' ) ); ?>

Related

Wordpress plugin menu issue

I am building a wordpress plugin with the boilerplate framework (https://wppb.me/). That all works fine. I have an annoying issues which I cannot solve.
the boilerplate makes per object one php file. In this php file all funtionality for the object is arranged. Pages, lists, validations etc.
Example in the file for contact there is a method contactlog_menu:
Object: contact
public function contactlog_menu()
{
add_submenu_page('plugin-options', __('plugin', 'plugin'), __('am_contactlogs', 'plugin'), 'manage_options', 'contactlogs', array($this, 'plugin_contactlogs_page_handler'));
add_submenu_page('contactlogs', __('New contactlog', 'plugin'), __('Add new b', 'plugin'), 'activate_plugins', 'contactlogs_form', array($this, 'plugin_contactlogs_form_page_handler'));
}
Now it shows a menu option in the left menu of wordpress. I would like to remove this menu option and create a hyperlink on the dashboardpage to this page. If i remove the lines wordpress is telling me i have no permission to view the page. what am i missing here
So i want to remove the menu item but want to page to be accessible as a link on another page. Otherwise my menu will become very large :-).
I hope it is understandable, otherwise please ask..
If you use null for the parent_slug parameter the page won't show up in the menu.
add_submenu_page(
null,
'My Custom Submenu Page',
'My Custom Submenu Page',
'manage_options',
'my-custom-submenu-page',
'callback_function' );
The page will be accessible via any parent slug, as long as it exists:
https://yoursite.com/wp-admin/options-general.php?page=my-custom-submenu-page
https://yoursite.com/wp-admin/tools.php?page=my-custom-submenu-page
https://yoursite.com/wp-admin/index.php?page=my-custom-submenu-page
...
Or no parent slug at all (same effect as if you'd use index.php):
https://yoursite.com/wp-admin/?page=my-custom-submenu-page
But it's probably best to use admin.php for your hyperlinks (the menu item that belongs to the slug you use will be active - if you use admin.php no menu item will be active):
https://yoursite.com/wp-admin/admin.php?page=my-custom-submenu-page

Moving WordPress default menus in admin

I've been digging around the codex trying to find a way to move the default menus around in the admin area. specifically i want to take the customizer from the appearance menu and move it to my custom menu. same with other menus. Is there a list somewhere of for them or a file to edit with the orders or way to move them. I don't want to edit any core files though as obviously will break on any update.
I already have my own menu: image of own menu code is below for mine.
function dcmaintheme_menu() {
add_menu_page( 'dcmaintheme_adminpage', 'Dragon Cove Theme', 'manage_options', 'dcmaintheme_adminpage', 'dcmaintheme_page', content_url( 'themes/dragon-cove-base/img/icon.png' ), 10 );
add_submenu_page( 'dcmaintheme_adminpage', 'Admin Options', 'Admin Options', 'manage_options', 'submenu_adminoptions_page', 'submenu_adminoptions_page' );
what id like to get is another sub-menu that links to say the appearance->customiser and have it in my custom menu.
You can use this plugin, it will allow you to customize the Admin Toolbar and the Admin Side menu. You can choose what content on the menu to display to a specific user role.

Wordpress - Different sidebar for each page

Client needs an website to migrate into WordPress.
In this website each page has an sidebar with different content inside it
In some page accordion comes under sidebar, in some just text and images are visible
How to implement this in WordPress?
If template has to be created, there are many page it cant be done so
Even for every page different sidebar widget is not also possible
Guide me a way to implement this
A different sidebar (widget) are can be added to each page in two steps:
Add the sidebar to the theme template using the page slug as part of the sidebar name. This ensures that the sidebar has a unique name for that page.
Register the sidebars for each page in functions.php for your theme
Add the sidebar to the theme template
In your theme template, add the following code where you want the widget area to be:
<?php
global $post;
dynamic_sidebar( 'widget_area_for_page_'.$post->post_name );
?>
Register the sidebars
In functions.php for your theme add the following block of code to register the sidebars for each page in your site. Note that it includes draft pages etc so that you can edit the widgets while still in draft mode.
function myTheme_registerWidgetAreas() {
// Grab all pages except trashed
$pages = new WP_Query(Array(
'post_type' => 'page',
'post_status' => array('publish', 'pending', 'draft', 'auto-draft', 'future', 'private', 'inherit'),
'posts_per_page'=>-1
));
// Step through each page
while ( $pages->have_posts() ) {
$pages->the_post();
// Ignore pages with no slug
if ($pages->post->post_name == '') continue;
// Register the sidebar for the page. Note that the id has
// to match the name given in the theme template
register_sidebar( array(
'name' => $pages->post->post_name,
'id' => 'widget_area_for_page_'.$pages->post->post_name,
'before_widget' => '',
'after_widget' => '',
'before_title' => '',
'after_title' => '',
) );
}
}
add_action( 'widgets_init', 'myTheme_registerWidgetAreas' );
Hope it helps!
There's a great plugin for this:
https://wordpress.org/plugins/custom-sidebars/
Sometimes it is necessary to show different elements on the sidebars
for some posts or pages. The themes nowadays give you some areas to
put the widgets, but those areas are common for all the posts that are
using the same template. NOTE: You need to use a theme that accepts
widgets to make this plugin work.
I think this is what you're looking for.
This can be done with the https://wordpress.org/plugins/jetpack/ plugin. Once activated you can choose what widgets display on what pages:
The Widget Visibility module enables you to configure widgets to appear only on certain pages (or be hidden on certain pages) by using the Visibility panel.
Visibility is controlled by five aspects: page type, category, tag, date, and author. For example, if you wanted the Archives widget to only appear on category archives and error pages, choose “Show” from the first dropdown and then add two rules: “Page is 404 Error Page” and “Category is All Category Pages.”
Just tried custom-sidebars with the latest version of wp. Had a hard time deleting it. Database is still messy. Plugin did not work. Maybe the 'pro' version is useful, but the 'non-pro' version would not add a sidebar to the page. It was clunky and did not allow per-page sidebars. It says its not been tested with the latest wp, maybe that's the problem.
You can create custom sidebar for for each post and pages with the help of plugin. There are a few plugins which enables you to create your custom sidebar. Here in this tutorial we are using Easy Custom Sidebars. Download and install this plugin in your website and activate it.
After successfully activating the plugin go to Appearance > Sidebar Replacement
From this page give a name to your custom sidebar and click on the Create Sidebar button. After that go to the Sidebar Properties option. Here you need to select the properties where you want to replace your created custom sidebar instead of theme sidebar. You can view your available option in the drop-down menu. Select it and provide a description on the Sidebar Description field.
Now in the last step select the post or pages to add this custom sidebar. You can see all the option in the left column. You can select specific post, page, category , tag, author to add this sidebar. Just select it and click Add to sidebar option.
For better understanding you can follow this tutorial

Drupal custom theme visibility to all users

I'm creating a custom drupal 7 theme
<?php print theme('links', array('links' => menu_navigation_links('menu-headermenu'), 'attributes' => array('class'=> array('links', 'headermenu')) )); ?>
Above is the code I'm using in my theme to show a menu I created using the Admin section.
My problem is the menu is getting displayed only for the Admin.
I want it to be shown to anonymous as well as registered users.
Also, I've tried changing the role permission by ticking 'Administer Block' and 'Administer menus and menu items' to all the three kind of users. Nothing helps.
Please help me..
I'm not 100% sure this will answer your question, because it side steps the code above - but, you could try enabling the Menu Block module, then using it to create a block based on your desired menu. Then you can place it any block region, and control it via the normal block controls.
The only trick of it is you might need to add a region to your template if it doesn't exist in the place that you want, but that's easy.

Need help with Wordpress menu and redirecting pages

I have a template with 2 menus, a top primary menu and a secondary menu.
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>
and these menu options :
Home
Projects
Contact
Now I have a secondary menu that is visible when someone accesses "Projects". and the follwing menu options :
Overview
Project A
Project B
Now in this scenario I have 6 pages, one for every menu option. But I do not want to use the "Project" page. If someone clicks "Porjects" on the primary menu, I want that the "Overview" page is actually loaded.
The second problem is with the style. When I have "Overview" activated I also want to have the secondary menu option "Overview" highlighted, which works, but also the menu option on the primary menu "Projects".
Any idea ?
At least for your first question, using the custom menu, you should be able to add the Overview page in place of Projects, and rename it Projects. That also may fix your second question as well.

Resources