$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom taxonomy - List posts with slug title|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom taxonomy - List posts with slug title

matteradmin9PV0评论

The code is for single-product.php. I can list all products on page but I want to list all posts with slug titles.

<?php
$args= array(
    'post_type'      => 'products',
    'order_by'       => 'date',
    'posts_per_page' => -1,
    'post__not_in'   => array( get_the_ID() ),
);

$wp_query = new WP_Query( $args );

while( $wp_query->have_posts() ) {
    $wp_query->the_post();
    echo '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
}

Example:

  1. Samsung ->(slug / category)
    • Galaxy note 5
    • Galaxy note 5
  2. Apple ->(slug / category)
    • Iphone7
    • Iphone8

The code is for single-product.php. I can list all products on page but I want to list all posts with slug titles.

<?php
$args= array(
    'post_type'      => 'products',
    'order_by'       => 'date',
    'posts_per_page' => -1,
    'post__not_in'   => array( get_the_ID() ),
);

$wp_query = new WP_Query( $args );

while( $wp_query->have_posts() ) {
    $wp_query->the_post();
    echo '<a href="' . get_the_permalink() . '">' . get_the_title() . '</a>';
}

Example:

  1. Samsung ->(slug / category)
    • Galaxy note 5
    • Galaxy note 5
  2. Apple ->(slug / category)
    • Iphone7
    • Iphone8
Share Improve this question edited Mar 6, 2019 at 11:35 Max Yudin 6,3982 gold badges26 silver badges36 bronze badges asked Mar 6, 2019 at 11:26 SmncSmnc 134 bronze badges 2
  • What is 'slug title'? – Max Yudin Commented Mar 6, 2019 at 11:38
  • i have 3 slugs ( samsung, iphone, lg,....) more slugs will create later.... – Smnc Commented Mar 6, 2019 at 11:50
Add a comment  | 

1 Answer 1

Reset to default 0

If by "slug title" you mean a taxonomy (e.g. product category), then have a look at the code posted on the accepted answer on Display All Products by Category with WooCommerce It should give you an idea (or even the complete solution) how to get your posts listed.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far