[DiscordArchive] is 418 the tag id for your category?
[DiscordArchive] is 418 the tag id for your category?
Archived author: Guybrush • Posted: 2023-01-04T15:58:47.759000+00:00
Original source
is 418 the tag id for your category?
Archived author: blacknightt • Posted: 2023-01-04T15:59:17.454000+00:00
Original source
```
function wpb_rand_posts()
{
$args = array(
'post_type' => 'post',
'orderby' => 'rand',
'posts_per_page' => 10,
'macro' => 535, // dungeon category
);
$the_query = new WP_Query($args);
if (!$the_query->have_posts()) {
return "No posts found";
}
// actually randomize
shuffle($the_query->posts);
$string .= '<ul>';
while ($the_query->have_posts()) {
$the_query->the_post();
$string .= '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
$string .= '</ul>';
wp_reset_postdata();
return $string;
}
add_shortcode('wpb-random-posts', 'wpb_rand_posts');
add_filter('widget_text', 'do_shortcode'); ```
Archived author: Guybrush • Posted: 2023-01-04T15:59:21.188000+00:00
Original source
there's a number of other things that might be happening that will probably get in the way if you're not already familiar with PHP
Archived author: Guybrush • Posted: 2023-01-04T15:59:40.216000+00:00
Original source
what is macro?
Archived author: Guybrush • Posted: 2023-01-04T16:00:23.266000+00:00
Original source
I figured it would come to this
Archived author: Guybrush • Posted: 2023-01-04T16:00:24.719000+00:00
Original source
https://developer.wordpress.org/referenc...parameters
[Embed: WP_Query | Class | WordPress Developer Resources]
The WordPress Query class.
https://developer.wordpress.org/referenc.../wp_query/
Archived author: blacknightt • Posted: 2023-01-04T16:00:36.834000+00:00
Original source
I gave the category and id of another collection
Archived author: Guybrush • Posted: 2023-01-04T16:01:05.088000+00:00
Original source
yes, but `macro` is not an expected element in the array you're giving to WP_Query
Archived author: Guybrush • Posted: 2023-01-04T16:03:20.323000+00:00
Original source
the array is saying "filter the `cat` to this `category_id`". There are a few other options you can use too, but refer to the documentation
```
cat (int) – use category id.
category_name (string) – use category slug.
category__and (array) – use category id.
category__in (array) – use category id.
category__not_in (array) – use category id.
```