Square brackets in URL (Custom Menus) (2 posts)

  1. Adam
    Posted 4 years ago #

    I have a URL that I need to put in my custom menu, but it contains square brackets [].
    Something like...

    When I do this, WP strips the brackets. I'm guessing it's because shortcode uses these.

    I've also tried using the ascii equivalent, which works the first time, but after updating, it displays the brackets, so any subsequent changes to the menu will remove the brackets.. unless I use ascii every time any menu item needs changing.

    Is there a way to do this? Do I need to add a filter?

    Thanks :)

  2. keesiemeijer
    Posted 4 years ago #

    As found in RFC 1738 documentation

    "Many URL schemes reserve certain characters for a special meaning:
    their appearance in the scheme-specific part of the URL has a
    designated semantics. If the character corresponding to an octet is
    reserved in a scheme, the octet must be encoded. The characters ";",
    "/", "?", ":", "@", "=" and "&" are the characters which may be
    reserved for special meaning within a scheme. No other characters may
    be reserved within a scheme.


    Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
    reserved characters used for their reserved purposes may be used
    unencoded within a URL."

    Look at serialize() and unserialize() for passing array and object data via POST or GET

Topic Closed

This topic has been closed to new replies.

About this Topic