显示所有woocommerce产品链接与标题在页脚SEO - Wordpress PHP


Displaying all woocommerce product liks with title in Footer for SEO - Wordpress PHP

我想在链接顶部显示所有woocommerce产品与woocommerce标题的链接,帮助我的SEO。我已经设法找到一些代码下面得到的产品类别,但似乎不能得到代码显示所有产品与链接的标题。

如果有人知道任何代码,可以帮助我,我会非常感激得到所有产品的链接和标题!p.s.如果有更好的方法来获取数据比我用过,请让我知道!

<?php
                  $taxonomy     = 'product_cat';
                  $orderby      = 'name';  
                  $show_count   = 0;      // 1 for yes, 0 for no
                  $pad_counts   = 0;      // 1 for yes, 0 for no
                  $hierarchical = 1;      // 1 for yes, 0 for no  
                  $title        = '';  
                  $empty        = 0;
                $args = array(
                  'taxonomy'     => $taxonomy,
                  'orderby'      => $orderby,
                  'show_count'   => $show_count,
                  'pad_counts'   => $pad_counts,
                  'hierarchical' => $hierarchical,
                  'title_li'     => $title,
                  'hide_empty'   => $empty
                );
                ?>
                                
                <?php $all_categories = get_categories( $args );
                //print_r($all_categories);
                foreach ($all_categories as $cat) {
                    //print_r($cat);
                    if($cat->category_parent == 0) {
                        $category_id = $cat->term_id;
                ?>  
                                    
                <?php       
                
                        echo '<a href="'. get_term_link($cat->slug, 'product_cat') .'">' . $cat->name .'</a>'; ?> |
                
                    <?php }     
                }
                ?>

这是你想要的吗?

//you can remove post_status=>publish if you want unpublished product also
$loop = new WP_Query( array( 'post_type' => 'product','post_status' => 'publish', 'posts_per_page' => '-1' ) ); 
while ( $loop->have_posts() ) : $loop->the_post();
    echo "<a href='".get_post_permalink()."'>".$loop->post->post_title."</a><br>";
endwhile;

更改查询:

$loop = new WP_Query( array( 'post_type' => 'product','post_status' => 'publish', 'posts_per_page' => '-1', 'orderby' => 'title', 'order' => 'ASC' ) );