Multiple arrays in post__not_in parameter
-
10-04-2021 - |
Pergunta
Does the post__not_in parameter can have multiple arrays for excluding, for example, sticky posts and also the IDs of some other posts?
Something like:
'post__not_in' => array(
get_option( 'sticky_posts' ),
array( 1, 2, 3 )
)
Solução
No, it doesn't. You'd just merge the arrays:
'post__not_in' => array(
array_merge( get_option( 'sticky_posts' ), array( 1, 2, 3 ) ),
)
And just because someone else will mention it if I don't: post__not_in
has terrible performance and you'd be better off finding an alternate solution.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a wordpress.stackexchange