Forums WoW Modding Support Archives TrinityCore Discord Archives [DiscordArchive] is 418 the tag id for your category?

[DiscordArchive] is 418 the tag id for your category?

[DiscordArchive] is 418 the tag id for your category?

rektbyfaith
Administrator
0
01-04-2023, 03:58 PM
#1
Archived author: Guybrush • Posted: 2023-01-04T15:58:47.759000+00:00
Original source

is 418 the tag id for your category?
rektbyfaith
01-04-2023, 03:58 PM #1

Archived author: Guybrush • Posted: 2023-01-04T15:58:47.759000+00:00
Original source

is 418 the tag id for your category?

rektbyfaith
Administrator
0
01-04-2023, 03:59 PM
#2
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'); ```
rektbyfaith
01-04-2023, 03:59 PM #2

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'); ```

rektbyfaith
Administrator
0
01-04-2023, 03:59 PM
#3
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
rektbyfaith
01-04-2023, 03:59 PM #3

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

rektbyfaith
Administrator
0
01-04-2023, 03:59 PM
#4
Archived author: Guybrush • Posted: 2023-01-04T15:59:40.216000+00:00
Original source

what is macro?
rektbyfaith
01-04-2023, 03:59 PM #4

Archived author: Guybrush • Posted: 2023-01-04T15:59:40.216000+00:00
Original source

what is macro?

rektbyfaith
Administrator
0
01-04-2023, 04:00 PM
#5
Archived author: Guybrush • Posted: 2023-01-04T16:00:23.266000+00:00
Original source

I figured it would come to this
rektbyfaith
01-04-2023, 04:00 PM #5

Archived author: Guybrush • Posted: 2023-01-04T16:00:23.266000+00:00
Original source

I figured it would come to this

rektbyfaith
Administrator
0
01-04-2023, 04:00 PM
#6
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/
rektbyfaith
01-04-2023, 04:00 PM #6

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/

rektbyfaith
Administrator
0
01-04-2023, 04:00 PM
#7
Archived author: blacknightt • Posted: 2023-01-04T16:00:36.834000+00:00
Original source

I gave the category and id of another collection
rektbyfaith
01-04-2023, 04:00 PM #7

Archived author: blacknightt • Posted: 2023-01-04T16:00:36.834000+00:00
Original source

I gave the category and id of another collection

rektbyfaith
Administrator
0
01-04-2023, 04:01 PM
#8
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
rektbyfaith
01-04-2023, 04:01 PM #8

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

rektbyfaith
Administrator
0
01-04-2023, 04:03 PM
#9
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.
```
rektbyfaith
01-04-2023, 04:03 PM #9

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.
```

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)