Timeline for Altering the main query using get_post_meta() in pre_get_posts
Current License: CC BY-SA 3.0
13 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 20, 2016 at 19:27 | comment | added | matjaeck |
As the question about the IDs was answered your example would be offtopic, but thank you for the input i will look into how to use get_option in this context.
|
|
May 20, 2016 at 19:23 | vote | accept | matjaeck | ||
May 20, 2016 at 18:51 | history | edited | matjaeck | CC BY-SA 3.0 |
szenario explained
|
May 20, 2016 at 18:29 | answer | added | stoi2m1 | timeline score: 1 | |
May 20, 2016 at 18:26 | comment | added | matjaeck | Sorry I have to correct this the metadata will be applied to pages not CPT. | |
May 20, 2016 at 18:24 | comment | added | matjaeck | I use CMB2 with attached-posts | |
May 20, 2016 at 18:22 | comment | added | Howdy_McGee♦ |
How are you saving the postmeta? via plugin or by the save_post hook or custom fields or...?
|
|
May 20, 2016 at 18:20 | comment | added | matjaeck | The metadata wil be applied to a CPT without any requirements to page or post attributes. If I modify the question, can you give an example? | |
May 20, 2016 at 18:13 | comment | added | Howdy_McGee♦ |
Do you set this on a post by post basis? If not it would be easier and probably better suited as an option then you could just use get_option() and be done with the whole thing.
|
|
May 20, 2016 at 18:12 | comment | added | matjaeck |
The meta value will contain an array of post IDs. I want to get these IDs and use $query->set ('post__in', array($myIDs)); to alter the main query.
|
|
May 20, 2016 at 18:05 | comment | added | Howdy_McGee♦ |
What kind of post meta do you need in a pre_get_posts hook? Why not save it as an option? Your errors probably relate to this bug in which get_queried_object() has the possibility of returning NULL to one of the normal conditionals. Have you tried $wp_query->is_front_page() instead?
|
|
May 20, 2016 at 17:54 | history | edited | matjaeck | CC BY-SA 3.0 |
deleted 464 characters in body
|
May 20, 2016 at 17:45 | history | asked | matjaeck | CC BY-SA 3.0 |