Add custom ID attribute to all woocommerce products on archive pages

Copy /woocommerce/templates/content-product.php to /yourtheme/woocommerce/content-product.php and modify it as needed. In this case, we can change the opening <li> tag from this: <li <?php post_class(); ?>> to this: <li <?php post_class(); ?> id=”<?php echo esc_attr( ‘post-‘ . get_the_ID() ); ?>”> The updated content-product.php file will look like this: <?php /** * The template for displaying product … Read more

Displaying Children of several pages

This is a working code. If you place the code in proper place it will surely gonna work [inshALLAH]. You can use this as a function or even shortcode. global $post; $parent_id = $post->ID; //if you are within a loop $childpages = new WP_Query([ ‘post_type’ => ‘page’, ‘post_parent’ => intval( $parent_id ), ‘posts_per_page’=> 3, // … Read more

Displaying logged in user name

The answer in your link is correct. If it’s just showing PHP code then your code isn’t between PHP tags <?php & ?>. <?php if (!is_user_logged_in()) :?> <a href=”https://wordpress.stackexchange.com/member-login/” class=”login”>Member Login</a> <?php else : ?> <a href=”http://wordpress.stackexchange.com/account-page/” class=”login”>Welcome <?php echo $current_user->display_name; ?></a> <?php endif; ?> <a href=”http://wordpress.stackexchange.com/membership/join-sccap-renew-membership/” class=”join”>Join</a>