0

I have a function which blacklists all public_query_vars and private_query_vars.

But wp-admin and wp-login aren't listed in these arrays. Is there a way to add them to these lists?

Original code:

    public function forbidden_slugs() {
        $wp = new WP;
        return array_merge( $wp->public_query_vars, $wp->private_query_vars );
    }

Something I tried but didn't work:

    public function forbidden_slugs() {
        $wp = new WP;
        return array_merge( $wp->public_query_vars, $wp->private_query_vars, 'wp-admin', 'wp-login' );
    }

Thank you!

1
  • array_merge merges arrays. 'wp-admin' is a string Commented Jul 14, 2016 at 14:04

1 Answer 1

2

Maybe try:

return array_merge( $wp->public_query_vars, $wp->private_query_vars, array('wp-admin', 'wp-login') );

You are using function that require array's as a parameter but you supply strings into it.

Sign up to request clarification or add additional context in comments.

3 Comments

I have tried your code but it seems to completely ignore the line now
i initially ommited return, maybe you have to add it in there
Ah yes, sorry! I said that right after I posted that comment. I will accept your answer when I'm allowed to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.