Skip to content

Instantly share code, notes, and snippets.

View rajucs's full-sized avatar
🎯
Focusing

Arman Hossain rajucs

🎯
Focusing
View GitHub Profile
Method -1
$args = array(
'hide_empty' => 0, //Show me all the categories, even the empty ones
'orderby' => 'count', //which accepts a string. You can pick from the following options: ID to order the categories by their ID (no, really?), name to sort them alphabetically (the default value), slug to sort them in the alphabetical order of their slugs, and count to order by the number of posts they contain.
'order' => 'DESC', //The chosen order can be reversed by setting DESC (descending) as a value for the order option (by default this option is set to ASC (ascending)).
'include' => '15,16,9'
);
wp_list_categories($args);
add_filter( 'the_title', 'shorten_woo_product_title', 10, 2 );
function shorten_woo_product_title( $title, $id ) {
if ( ! is_singular( array( 'product' ) ) && get_post_type( $id ) === 'product' ) {
return wp_trim_words( $title, 3, '...' ); // change last number to the number of words you want
} else {
return $title;
}
}
Method-1
Add this line to your theme function.php
/ remove product category and tag from single product page
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
Method-2
Add these css to your style.css file
.single-product .product_meta {
<?php
$product_tags = get_terms( 'product_tag');
$i=0;
foreach ( $product_tags as $product_tag ) {
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'product_tag',
// These are actions you can unhook/remove!
add_action( 'woocommerce_before_single_product', 'wc_print_notices', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_sale_flash', 10 );
add_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 );
add_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
run this command
php -S 127.0.0.1:9000 -t public/
now test to your browser.
after this run
php artisan serve
hope it will works fine
.site-header {
position: fixed;
top: 0;
width: 100%;
z-index: 2000;
}
body .site-inner {
top: 77px;
}
body {
<ul class="products">
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'shoes', 'orderby' => 'rand' );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<h2>Shoes</h2>
<li class="product">
<a href="<?php echo get_permalink( $loop->post->ID ) ?>" title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>">
<?php woocommerce_show_product_sale_flash( $post, $product ); ?>
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" width="300px" height="300px" />'; ?>
<div class="row">
<?php
$args = array( 'post_type' => 'product', 'posts_per_page' => 8, 'product_cat' => 'Leather', 'orderby' => 'title','order' => 'ASC', );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
.widget li > ul, .widget li > ol{
display: none;
}