Exclude category and post from loop in custom category.php

Here is a correct way: <div id=”category__product-grid” class=”row”> <?php query_posts( array( ‘cat’ => array(6,-45), ‘post__not_in’ => array(-598), ‘orderby’ => ‘title’, ‘order’ => ‘ASC’ ) ); ?> <?php // The Loop while ( have_posts() ) : the_post(); ?> <div class=”col-md-4 col-product-item”> <a href=”https://wordpress.stackexchange.com/questions/321415/<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><div class=”cat__featured-img”><?php the_post_thumbnail(); ?></div></a> <h2><a href=”https://wordpress.stackexchange.com/questions/321415/<?php the_permalink() ?>” … Read more

How to make this code valid only when the value exists?

If we refer to the documentation, we see that get_the_terms returns an array, false, or a WP_Error object. So in our code we’ll add a check if $collection_values exists (it’s not false), and it’s not an error, then we’ll know it has to be an array, and it’s safe to run a foreach loop on … Read more

Allow user to choose header style

Do you want this to be an option per page? Or side wide. If first, look into this: https://www.advancedcustomfields.com/ If second, look into this: https://blog.templatetoaster.com/wordpress-settings-api-creating-theme-options/

Add custom attribute to product’s HTML to woocommerce cart page

You want to override the file, not edit it directly. How to Edit Files Edit files in an upgrade-safe way using overrides. Copy the template into a directory within your theme named /woocommerce keeping the same file structure but removing the /templates/ subdirectory. Example: To override the cart.php file… copy: wp-content/plugins/woocommerce/templates/cart/cart.php to wp-content/themes/yourtheme/woocommerce/cart/cart.php The copied … Read more

Getting an empty space in up sell items

The issue I was having was that the query calling the items was checking to see if the main item (i.e. the product the user clicked on) was in stock, not the actual up sell items. Can add code snippets later if needed