您使用的是回声输出的\\u permalink,因此您以回声输出。您希望sue get\\u the\\u permalink返回url,然后可以将url回传到代码中。大多数wordpress函数以“\\uDirect echo out”开头,以“get\\u1”返回结果。
这应该对你有用。我还使用了\\u post\\u缩略图显示wordpress格式的缩略图图像,并使用超链接更新问题。
<ul class="product-menu">
    <?php
    $args = array(
        \'post_type\' => \'product\',
        \'post_status\' => \'publish\',
    )
    $products = new WP_Query($args);
    while ( $products->have_posts() ) {
        $products->the_post();
        echo \'<li><a href="\' . get_the_permalink() . \'">\';
        // check if the post has a Post Thumbnail assigned to it.
        if ( has_post_thumbnail() ) {
            the_post_thumbnail();
        }
        echo \'</a></li>\';
    } 
    /* Restore original Post Data */
    wp_reset_postdata();
    ?>
</ul>