I am working on a WordPress shop. I am using the WooCommerce plugin.
I need to add a second responsive menu. The problem is, that menu items will change depending on the page. For example, the menu needs to be different for the 'shop' page and the 'about' page.
Without WooCommerce (in pure WordPress), I would simply use different header templates for each page (by using page templates). In WooCommerce it seems to work differently.
I don't want to use plugins. How can I do it?
If you have access to the source, you can use conditionals in PHP.
For example:
if(is_page(('shop')) :
('your_shop_menu'); // consider fix this php, it's example only (you can use is_shop() when is Woocommerce Home Shop)
elseif(is_page(('about')) : // You can use page's slug
('your_about_menu'); // consider fix this php, it's example only
else :
('your_default_menu'); // or empty if you don't need menu
endif;
Please see
https://docs.woothemes.com/document/conditional-tags/
https://codex.wordpress.org/Conditional_Tags
Edit: You can manage differents menus via WP Admin
Menu for Shop Page
Menu for About Page
Related
I am running the latest version of WordPress along side a classic/legacy custom theme.
My issue is I am trying to add a header above posts on the news page, but this header gets applied to EVERY post.
Is there any way to add this content to just the news page and not individual posts?
I would like the news page elements to show up on only the news page, and to be able to separately style the template for posts.
use the function is_page() define which page you want to target (Codex)
for example if your page slug is 'news'
if( is_page('news'){
//your code
}
I have a website that is using WooCommerce to sell items. Here is my demo site:
http://demo.bergdahl.com/
You can see the ecommerce pages and their layouts here:
Layout 1 (left and right sidebars):
Products list: http://demo.bergdahl.com/shop/
Category page: http://demo.bergdahl.com/product-category/catridges/
Layout 2 (right sidebar only):
Single product page: http://demo.bergdahl.com/product/6-oz-catridge/
I have gotten it so that most of the WooCommerce pages use have layout 1 except the single product page that has layout 2. Layout 2 is set to be the default layout in the theme and applies to the other 170 pages of the site. I don't want to change the default layout, I just want to find out what page I can use to set the layout for the single product page.
Basically, I would like to have all WC pages use layout 1.
My question is, how does WooCommerce chose which layout is assigned to which type of page?
It seems like the Product list and the Category pages are pulled in from the blog page layout. The Cart, Checkout, and My Account pull from their actual pages. I am not sure how to set the layout in the single product page.
P.S. - This site uses an older theme with no WC support. I don't know if this may be the problem but I could only adapt the theme by using the woocommerce_content() method listed here: https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/?utm_source=notice&utm_medium=product&utm_content=themecompatibility&utm_campaign=woocommerceplugin
You can override the singe product template.
To override the single product template, copy:
wp-content/plugins/woocommerce/templates/single-product to
wp-content/themes/Builder/woocommerce/single-product
There is an official documentation for WooCommerce theme override at Template Structure + overriding templates via a theme.
Thanks to Lax, I found a way around it. I actually used the woocommerce.php that I created out of my theme's page.php. This got it out of the same container that the product was in.
I then used the dynamic_sidebar('sidebar_name_here') to display the sidebar on that page . The full code I used was:
<?php if(is_product()){?>
<div class="store-sidebar-left">
<?php dynamic_sidebar('store-sidebar-left');?>
</div>
<?php } ?>
This allows it to only show on the single product page.
I had one small problem where I couldn't find the name of the sidebar in my theme or my database so I just created a new on in my functions.php file and used that one.
I would like to let the user choose between different templates, such as full with or content with sidebar for the Shop page, but the problem is that the shop page always uses the archive-product.php template.
Thank you
Make a regular (not shop) page and add this shortcode:
[products orderby="menu_order"]
Other options to customize are available here:
https://docs.woocommerce.com/document/woocommerce-shortcodes/
To make your different templates, just make custom page templates as you would for any page:
https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/
...And then select the template from the Page Attributes menu for that page, typically on the right about half way down. Now you can set up different shop pages with different text and layouts, and the savvy client can change between the templates you build.
Also note, when you use the shortcode above for a custom shop page, you can put in-page CSS. Just wrap it in <style</style> tags, though many frown on that practice.
I am creating simple plugin, and I prepared few pages: add.php, edit.php, delete.php and list.php. I've used add_menu_page and add_submenu_page - so I understand why they are visible in admin menu. How to create page (or custom URL with parameter) without putting this into menu? I'd like to add link to edit page and delete url (code executed by plugin) on listing page - something like in posts listing page but can't find function to achieve this.
Here are two possible solutions for this questions:
How do you add a WordPress admin page without adding it to the menu?
Personally i havent tried it but it like the one where you remove the item from the menu after you set things up like normal.
There is also a great plugin called the WP Router that can help you setup totally unique urls with the callback you desire.
Quick question (quick deadline...I know I can use google).
I'm writing a site on Wordpress w/ a static home page, it has a few pages--I want the 'blog' page to show the wp entries...what's the best way to set this up.
Right now I have a static template for each page (with content rendered), but of course, the blog page doesn't show the posts...
Thanks for the help!
Create a Wordpress Page Template by making a page with any name and this comment at the top:
/*
Template Name: Blog Enitres
*/
Go create a page, use that as the template (there is a selector on the right hand side). Call it whatever and save it. This is your static page.
Then, after that, go down to Settings > Reading and change the 'Home' page to be the page you've created.
Then create an index.php and save it. This will be the template for the displayed posts. Create an empty page and select it at the 'Posts Page' in settings.
To learn more about this functionality go here.
To learn more about the Wordpress loop and how to display entries, visit codex.wordpress.org