i have this Woocommerce site and i want to display 6 products per row. I try adding some code to functions.php and changing li width with css. Here is the website: codedoors.com/styleindia. Too i tried WooCommerce Product Archive Customizer plugin but not work.
My functions.php file:
// Display 24 products per page. //working
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 9;' ), 20 );
// Change number or products per row to 3 //not working
add_filter('loop_shop_columns', 'loop_columns');
if (!function_exists('loop_columns')) {
function loop_columns() {
return 6; // 3 products per row
}
}
Thank you
I have made 6 products to display per row using the CSS style itself. I will provide you with the style how i have changed it.
Stylesheet 1:
Hide the line that i have mentioned below
http://codedoors.com/styleindia/wp-content/themes/smartshop/assets/css/smartshop-woocommerce.css?ver=1.0
.woocommerce ul.products li.product:nth-child(4n+1) {
/*clear: both !important;*/
}
And in the same file change the style of selector to this
.woocommerce ul.products li.product {
clear: none !important;
margin: 2% !important;
width: 12% !important; /* you have given here it as 15% */
}
And final one is to apply the style for the UL class .products and you can paste this anywhere you want but if is not been applied put it under important tag.
.products {
float: left;
width: 100%;
}
Here is the screen shot that have made by applying the style that i have sent to you. http://www.awesomescreenshot.com/image/1480013/f65662d652f36b254a9882ce4ba6011a
Hope this solution helps you.
Related
I have a Multisite with a main domain (www.valleysgroup.co.uk) and various sub-domains (brickslipsdirect.valleysgroup.co.uk, tradeporcelain.valleysgroup.co.uk etc).
I am wanting to share a custom top bar containing a menu that is not the primary menu of the main domain, from the main domain across all the sub-domains. This menu will be simple links to each of the sub-domains, but in the form of tabs. Tab 1 will lead to brickslipsdirect.valleysgroup.co.uk, tab 2 will lead to tradeporcelain.valleysgroup.co.uk etc.
I have spent several days trying various solutions, which I then came across the plugin: Multisite Shared Menu
This works great, apart from it will only apply the primary menu from the main domain, and no other menu's. Ideally I would like to create a new menu location named Global Top Bar on the main domain and all subs, create my menu named Global Menu on the main domain, and then pull the menu into all the subs.
I am also unsure how to implement this on the main domain and sub-domains as tabs instead of a general horizontal, dropdown or list menu.
Please see image for clarity on what I am looking for looks-wise across the main domain and the subs:
Any help would be greatly appreciated!
Unfortunately I don't have too much time to spend on this, but hopefully you or someone you know can help flesh this out more.
I've added a bunch of comments that should hopefully explain most things. You just need to plug in the IDs for each site as you find in the Multisite backend. This code will kick out an unordered list with one entry per site, and the current site having a special class. You will probably want to add some additional classes but hopefully this is enough to get you somewhere at least.
// Just the Site IDs from WordPress
$siteIds = [2, 3, 4];
// This will hold <li> tags for each
$menuItems = [];
foreach ($siteIds as $siteId) {
// Get the WordPress WP_Site object
$site = get_site($siteId);
// Sanity check that it was found and public
if (!$site || !$site->public) {
continue;
}
// Optional attributes classes on the <li>, default none
$extraAttributes = '';
// For the current site, add a class
if ($siteId === get_current_blog_id()) {
$extraAttributes = ' class="current-site"';
}
// Append an HTML node
$menuItems[] = sprintf(
'<li %3$s>%1$s</li>',
esc_html($site->blogname),
esc_attr($site->siteurl),
$extraAttributes
);
}
// Make sure the above worked
if ($menuItems) {
// Output wrapped
echo '<ul>' . implode('', $menuItems) . '</ul>';
}
I have now gone ahead and added my new menu location named Global Top Bar using the following in my main domains Child Theme > Functions.php file:
function register_new_menu_location() {
register_nav_menu('global-menu-location',__( 'Global Top Bar' ));
}
add_action( 'init', 'register_new_menu_location' );
I have also created my menu named Global Menu and marked for it to display in the newly made location.
I have then gone into my Child Theme > Header.php file and added the following which seem to work:
switch_to_blog(1);
wp_nav_menu( array(
'menu' => '16',
'container_class' => 'GlobalMenuContainerClass',
'menu_class' => 'GlobalMenuClass'
) );
restore_current_blog();
Menu '16' being my menu's ID found on my main domain. This displays the menu on all sub-domains like this:
I Added some CSS to spice it up a little and make it look more like tabs using the following CSS code:
.GlobalMenuContainerClass {
height: 45px;
padding-top: 8px;
padding-right: 100px;
padding-left: 100px;
width: 100%;
margin-right: auto;
margin-left: auto;
background: #cc2325;
}
.GlobalMenuClass {
list-style: none;
margin: 0;
padding: 0;
}
.GlobalMenuClass li a {
text-decoration: none;
float: left;
margin-right: 5px;
color: white;
border: 1px solid #777777;
padding: 5px 10px 5px 10px;
min-width: 100px;
text-align: center;
display: block;
background: #777777;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.GlobalMenuClass li a:hover:not(.active) {
background: #4e4e4e;
border: 1px solid #4e4e4e;
}
.active {
background: white;
color: black;
border: 1px solid white;
}
And here is how it now looks:
You can see there is a different hover colour for the tabs of a darker grey, but I have not yet implemented the .active tab CSS yet. Not quite sure how I am going to do this yet.
Hope this can help others in a similar situation.
I am using Wordpress and WooCommerce to build a website for my client. For every product page I have set up two groups of links (buttons, secondary menu) to allow user to visit other product category pages. I would like certain links to be automatically a specific color and weight when the user is on a certain product page (like an active state, but without having to first clicked on the link, I guess similar to breadcrumbs to show where the user is in terms of what category/categories the product they're viewing belongs to).
I've been trying to target the post-id and the div of the specific links to make css changes, but it's not working. I would really appreciate any help!
Here is the css I used to target a specific secondary menu link:
#menu-item-1886 > a {
color: #003b59 !important;
font-weight: 600;
}
This works, but of course it made the change to this menu item across all pages. I want it to be only on a specific product page.
I also tried this, which also didn't work:
.body.post-id-766 #menu-item-1886 > a {
color: #003b59 !important;
font-weight: 600;
}
The site is at http://www.hoptri.d-gecko.com
Again, really would appreciate your help with this! Thanks in advance!
You can add with body_class WordPress filter hook and choosen conditional tags some additional classes where you want, like in this example:
add_filter( 'body_class', 'adding_some_custom_body_classes' );
function adding_some_custom_body_classes( $classes ) {
if ( is_product() ) {
$classes[] = 'product-single-pages';
} elseif( is_product() && is_single( array( 17, 19, 1, 11 ) ) {
$classes[] = 'product-single-pages-2';
}
return $classes;
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
This code is tested and works
So you will be able to use that classes selectors in your CSS rules like (fake example):
body.product-single-pages #menu-item-1886 > a,
body.product-single-pages2 #menu-item-1886 > a { font-weight: 600; }
body.product-single-pages #menu-item-1886 > a { color: green !important; }
body.product-single-pages2 #menu-item-1886 > a { color: red !important; }
WooCommerce inject yet in body classes some specific classes as in this html example:
<body class="product-template-default single single-product postid-19 logged-in woocommerce woocommerce-page right-sidebar woocommerce-active customize-support">
So you can also use this class selectors in your css:
single-product
woocommerce
woocommerce-page
woocommerce-active
For example this way:
body.woocommerce.single-product.woocommerce-active #menu-item-1886 > a {
color: blue !important;
}
References to conditional tags:
Wordpress conditional tags list
WooCommerce conditional tags list
I have my wordpress blog www.technikes.com .
you can see that all items are displayed on menu on desktop/laptop,But when I open the same blog on mobile then all menu items are replace by toggle menu button(three lines) as you can see here
blog on mobile with main menu three line button
what i am trying is all my items of menu (java,android,technology,about,contact) should be displayed in mobile as it is displaying in desktop.I donot want three line main menu button in mobile.
what I already tried:-
I installed plugins like "responsive menu" and "Max Mega Menu" and "Menu Items Visibility Control" on wordpress dashboard.
I try to change my "media screen and (min width 600px)" section under style.css of my theme.
I try to change breakpoint at which menu start appearing(by default it is 600px).
None of them work.
please suggest some solution.Thanks
Please take a backup before you change anything.
Open style.css
On line number 900, Change
#main-nav-button, #top-nav-button {
display: inline-block;
}
to
#main-nav-button, #top-nav-button {
display: none; // it will hide the button coming on mobile.
}
On line 655
Change
.main-navigation {
display: none;
}
to
.main-navigation {
display: block; // this will display the desktop navigation
}
Also on line 687
Change
.main-navigation ul, .top-navigation ul {
display: none;
}
to
.main-navigation ul, .top-navigation ul {
display: block;
}
And your end result will be(please check image)
Result
I want to add a background picture to a group of pages in wordpress.
I want to add a different background picture to another group of pages
Currently I am applying it to each individual page using PageID as in the code below. As there are over 1000 pages. Is there are a more simple way to apply to each group of pages?
.page-id-264 #header .logo a,
.page-id-272 #header .logo a {
background-image: url("http://www.richcoward.com/newcges/wp-content/uploads/2014/08/NWU-No-Frame.png") !important;
background-size: 100% !important;
background-repeat: no-repeat !important;
height: 86px !important;
width: 416px !important;
}
Thanks for your help
Here is a simple solution.
Create a custom css (say mystyle.css) file in your theme folder. Add
#header .logo a {
background-image: url("http://www.richcoward.com/newcges/wp-content/uploads/2014/08/NWU-No-Frame.png") !important;
background-size: 100% !important;
background-repeat: no-repeat !important;
height: 86px !important;
width: 416px !important;
}
into your mystyle.css. Now, open up your functions.php and enqueue your stylesheet conditionally. Use is_page() or is_page_template() conditional checks. I believe that you are talking about groups of pages, so I would imagine that you use specific page templates for specific groups, so I would tend to go for is_page_template
function enqueue_custom_style() {
if(is_page_template('page-whatever.php')) {
wp_enqueue_style('my-style', get_stylesheet_directory_uri() . '/mystyle.css' );
}
}
add_action('wp_enqueue_scripts', 'enqueue_custom_style', 999);
This should give you an idea
You could use a filter in your functions.php file to add a class to all the relevant pages. You're still going to have to rattle off each Page ID, but I guess doing it in PHP will keep your CSS smaller (and therefore load faster):
// Add specific CSS class by filter
add_filter( 'body_class', 'my_class_names' );
function my_class_names( $classes ) {
// array of Page IDs
$pageids = array(264, 272);
// if
if ( is_page( $pageids ) ) {
// add 'class-name' to the $classes array
$classes[] = 'class-name';
// return the $classes array
return $classes;
}
}
Alternatively, create page templates for each background.
I am trying to add some css to portfolio pages only on my word press site.
An example page is:
http://www.1aproductions.co.uk/portfolio/22/
The css code i am trying to add is:
.header-wrapper {
background-position:top;
background-color:transparent !important;
background-image:url('http://www.1aproductions.co.uk/wp-content/uploads/2014/06/Florence-Nightingale-smaller-no-flo.jpg') !important;
background-size: 100% auto;
}
Which would display a similar effect to the header on this page (if I could only get it to work!)
http://www.1aproductions.co.uk/work/?cat=dramas
Any Help would be greatly appreciated!
Thanks
P
It looks as though portfolio is a custom post type. So try this:
function my_custom_css() {
if ( is_singular( 'portfolio' ) ) {
echo "<style>
.header-wrapper {
background-position:top;
background-color:transparent !important;
background-image:url('http://www.1aproductions.co.uk/wp-content/uploads/2014/06/Florence-Nightingale-smaller-no-flo.jpg') !important;
background-size: 100% auto;
}
</style>";
}
}
add_action( 'wp_head', 'my_custom_css' );
See the classes of body
single single-portfolio postid-22 siteorigin-panels fixed-header no-slider dark-header --- on portfolio
page page-id-7 page-template page-template-template-portfolio-gallery-php siteorigin-panels fixed-header no-slider dark-header --- on categories.
You can add your specific background using that classes.
.single-portfolio .header wrapper{
background: xxx;
}
and
.page-id-7 .header wrapper{
background: yyy;
}