• Ok as asked in previous post to start a new post..

    i was kindly given this code to display random products in my 404 page

    <ul class="products">
    	<?php
    		$args = array(
    			'post_type' => 'product', //don't change
    			'posts_per_page' => 12, //change to number of posts you want to display
    			'orderby' => 'rand'
    			);
    		$loop = new WP_Query( $args );
    		if ( $loop->have_posts() ) {
    			while ( $loop->have_posts() ) : $loop->the_post();
    				woocommerce_get_template_part( 'content', 'product' );
    			endwhile;
    		} else {
    			echo __( 'No products found' );
    		}
    		wp_reset_postdata();
    	?>
    </ul><!--/.products-->

    This also displays the Product Short Description here as well.

    is there anyway to remove the wording that has been put in the Product Short Description part of the Product page and just have the image and other data there.
    Like a “dont add the Product Short Description’ part as well??

    thanks

    https://www.ads-software.com/plugins/woocommerce/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Try this in your custom css;

    .product_details .product_excerpt {display:none}

    If it doesn’t work, maybe your markup is different to mine, so please post a url where this code can be seen in action.

    Thread Starter wealthy

    (@wealthy)

    Oh I only wanted it to NOT show in the 404 page within the code I was given above.
    I believe if i put it in the custom code area it will stop it showing all over the site..

    Thanks

    Have a look for an id or class name in the 404 which doesn’t appear on other pages, and put that in front of the above css. For better advice please post a url to a 404 page.

    Hi wealthy,

    what you need to change is this part of the code:

    woocommerce_get_template_part( 'content', 'product' );

    basically, what that code does is call the content-product.php in the WooCommerce template folder. I believe the best way to do this is to create a custom template in your theme, and change that line with your new template. Say your template is content-product404.php then the code should be:

    woocommerce_get_template_part( 'content', 'product404' );

    Hope this helps!

    Thread Starter wealthy

    (@wealthy)

    ok thanks..
    Was more hoping that the code above could have been modified rather than creating yet another file / template..

    anyway I will have a look..

    Hi wealthy you can actually do your changes on that same template, but it’s not recommended structure wise. You’ll just have to copy the content from the product template and replace the woocommerce_get_template_part( 'content', 'product' );

    But it is really suggested to follow the template, so you can use your new structure for your product on other custom loops that you will add.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘404 page showing Random products’ is closed to new replies.