On my developer site this query is used for a carousel in index.php :
$vedette_accueil = new WP_Query(array(
'tag' => 'vedette-accueil',
'nopaging' => true,
'post_type' => array('post','mensuels')
));
mensuels
is a simple custom post type with post abilities and uses the post_tag
taxonomy. it is used to present a few articles of particular interest - described in a paragraph - for a given month.
It works as intended. It shows up in the carousel as intended.
On the production server, my cpt does not show up in the carousel. Every thing else about it works just fine: its pages work, it's there in the tab assigned to it in the index page, but just won't show up in the carousel. I even do a wp_reset_postdata()
between queries.
The only difference between implementations is that I named it themes_mensuels
rather than mensuels
. that's it. I pick the tag from the list, I can see it stick to my cpt because I have proper results in admin:
[mysite.ca]/wp-admin/edit.php?post_type=themes_mensuels&tag=vedette-accueil
Here are the first few lines of var_dumps
of the query. First, DEV (that works):
object(WP_Query)#11489 (49) {
["query"]=>
array(3) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(8) "mensuels"
}
}
["query_vars"]=>
array(64) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(8) "mensuels"
}
Here is PROD:
object(WP_Query)#10593 (49) {
["query"]=>
array(3) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(15) "themes_mensuels"
[1]=>
string(4) "post"
}
}
["query_vars"]=>
array(64) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(4) "page"
}
The funny thing is that i can query "just" the post type and see the few I have in the carousel. But when I add the tag, it just bumps the cpt.
I did a bit of research and the naming seems conventional. I added the recommendation from here.
but to no avail.
What very subtle WP idiosyncrasy am I missing??
On my developer site this query is used for a carousel in index.php :
$vedette_accueil = new WP_Query(array(
'tag' => 'vedette-accueil',
'nopaging' => true,
'post_type' => array('post','mensuels')
));
mensuels
is a simple custom post type with post abilities and uses the post_tag
taxonomy. it is used to present a few articles of particular interest - described in a paragraph - for a given month.
It works as intended. It shows up in the carousel as intended.
On the production server, my cpt does not show up in the carousel. Every thing else about it works just fine: its pages work, it's there in the tab assigned to it in the index page, but just won't show up in the carousel. I even do a wp_reset_postdata()
between queries.
The only difference between implementations is that I named it themes_mensuels
rather than mensuels
. that's it. I pick the tag from the list, I can see it stick to my cpt because I have proper results in admin:
[mysite.ca]/wp-admin/edit.php?post_type=themes_mensuels&tag=vedette-accueil
Here are the first few lines of var_dumps
of the query. First, DEV (that works):
object(WP_Query)#11489 (49) {
["query"]=>
array(3) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(8) "mensuels"
}
}
["query_vars"]=>
array(64) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(8) "mensuels"
}
Here is PROD:
object(WP_Query)#10593 (49) {
["query"]=>
array(3) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(15) "themes_mensuels"
[1]=>
string(4) "post"
}
}
["query_vars"]=>
array(64) {
["tag"]=>
string(15) "vedette-accueil"
["nopaging"]=>
bool(true)
["post_type"]=>
array(2) {
[0]=>
string(4) "post"
[1]=>
string(4) "page"
}
The funny thing is that i can query "just" the post type and see the few I have in the carousel. But when I add the tag, it just bumps the cpt.
I did a bit of research and the naming seems conventional. I added the recommendation from here.
but to no avail.
What very subtle WP idiosyncrasy am I missing??
Share Improve this question edited Apr 5, 2019 at 16:48 Qaisar Feroz 2,1471 gold badge9 silver badges20 bronze badges asked Apr 3, 2019 at 19:00 SassinakSassinak 216 bronze badges 12- Can you spot something in debug.log? – middlelady Commented Apr 3, 2019 at 19:12
- 1 Now is the right time to learn how to use it. Will get back with info – Sassinak Commented Apr 3, 2019 at 19:56
- Is this supposed to do anything: define( 'SAVEQUERIES', true ); cause I have unrelated errors so far. – Sassinak Commented Apr 3, 2019 at 20:48
- I will rename my CPT to be the same as in DEV. If that helps, I will be disappoint in WP for such a silly fault – Sassinak Commented Apr 4, 2019 at 15:18
- well, it was a lot of messing about, and the cpt is now named "mensuels" just like it is in dev, Everything works as expected EXCEPT it STILL won't appear in the carousel. I furthered my research by closely comparing the var_dumps of both DEV and Prod. Apart from the result, no other differences show up. – Sassinak Commented Apr 4, 2019 at 19:55
1 Answer
Reset to default 1I ended up using
'tag_slug__in'=>array( 'vedette-accueil'),
and now it works. How this is different from
'tag' => 'vedette-accueil',
and how the later would transform the query so that the cpt was ignored, I may never know...but I would love it if someone told me.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745623714a4636676.html
评论列表(0条)