• I’m new to WordPress, but am getting to grips with it quite quickly. However, I’ve come across an issue that I’d appreciate help with.

    I have one site that I want to link to that includes some square brackets in the URL. When I paste this into WP it strips the square brackets out, with the result that I finish up on a different webpage. Even if I manually re-insert the brackets, WP strips them out again. Why does this happen, and how can I prevent it happening?

Viewing 15 replies - 1 through 15 (of 21 total)
  • I think your problem is that WP sees anything inside square brackets as a shortcode, and is filtering it as such when you output the_content

    You can disable the functionality with this in your functions.php file

    remove_filter('the_content', 'do_shortcode');

    But sadly, that will stop all shortcodes from working, which may or may not be an issue for you.

    Thread Starter raywp

    (@raywp)

    Thanks for your rapid response Jackson. It’ll take me a while to digest what you have said (I’m not a very code aware person), but I can probably find the functions.php file and try adding the line of code you gave me and see if it’s ‘an issue for me’.

    Ray

    Thread Starter raywp

    (@raywp)

    Well, I didn’t manage to find the functions.php file More help, please.

    Ray

    Thread Starter raywp

    (@raywp)

    I’m clearly out of my depth here. I thought I’d just need to look at the WordPress installation on my server using ftp and find a file called functions.php and modify it. I’ve looked, I think, in all directories and haven’t found that file or a theme directory. It’s clearly not as simple as that. I really appreciate your help, but I suspect I’m completely on the wrong track.

    You need to look in

    /wp-content/themes/your_active_theme/

    Should you find no ‘functions.php’ file amongst ‘header.php’, ‘footer.php’, ‘index.php’, etc… you can safely create a new one with this as the content:

    <?php
    remove_filter('the_content', 'do_shortcode');
    ?>

    Save that file to /wp-content/themes/your_active_theme/ and WP will load it everytime your site loads.

    Thread Starter raywp

    (@raywp)

    OK. I found /wp-content/themes/ but the only directories under that are twentyeleven and twentyten. Not your_active_theme.

    I’m still working with the default theme. Could this explain that?

    Can I just go ahead and create a directory called your_active_theme and create a functions.php file and drop it into that? Or is that too simplistic?

    Thread Starter raywp

    (@raywp)

    In case it influences things. I have created a network so that I can eventually create multiple blogs. I know, that may sound as though I know more than I am letting on, but it took me a while, and I just followed WP instructions!

    your_active_theme = whatever you’re using, ie: twentyeleven?

    Thread Starter raywp

    (@raywp)

    Finally the penny drops. Thank you for your patience. I’ll go off and create myself a function.php file and let you know how I get on.

    Thread Starter raywp

    (@raywp)

    Actually, I found a functions.php file in the twentyeleven directory. I didn’t notice it before. The last couple of lines (after I’d added your original remove_filter suggestion) are:

    if ( is_singular() && ! is_home() && ! is_page_template( ‘showcase.php’ ) && ! is_page_template( ‘sidebar-page.php’ ) )
    $classes[] = ‘singular’;

    return $classes;
    }
    add_filter( ‘body_class’, ‘twentyeleven_body_classes’ );remove_filter(‘the_content’, ‘do_shortcode’);

    but this hasn’t changed my original issue, even though I manually added the brackets back in the URL. Maybe I haven’t modified the code correctly?

    A link to your site might be helpful to see your issue in person.

    Also paste your functions.php file in entirety here: https://pastebin.com/, and then post the link.

    Thread Starter raywp

    (@raywp)

    Thanks yet again.

    Here is the link I want to use:
    https://www.viewranger.com/buddybeacon/v2/?bb%5B0%5D=rayonfoot;0203&date_from=22/08/2011&date_to=23/08/2011&timezone=Europe/London

    WP removes the square brackets after the 0 following ?bb. If you remove those links it logs into the site in a different way. Ie,

    https://www.viewranger.com/buddybeacon/v2/?bb0=rayonfoot;0203&date_from=22/08/2011&date_to=23/08/2011&timezone=Europe/London

    For your information, this link allows me to show my location to others when I am walking long distance routes etc. What you see with the first link is just a test run. If you zoom in, you will see that I can add Twitter messages. The second URL shows activity over the same date range, but shows everybody using the system at that time.

    Do I need to log into pastebin for you to pick up the functions.php file, or will you see it anyway? If I need to login. What login should I use?

    I’m in the UK, so at some point I will go to bed, but I’m enjoying your support, so I’ll leave that as long as I can!

    Thread Starter raywp

    (@raywp)

    Now I notice that even this post has stripped out the square brackets.

    I’ll try and repeat it here:

    https://www.viewranger.com/buddybeacon/v2/?bb%5B0%5D=rayonfoot;0203&date_from=22/08/2011&date_to=23/08/2011&timezone=Europe/London

    No login required, just go to wordpress.pastebin.com

    I meant a link to the site where you’re trying to modify the functions.php file.

    Ironically, the forums are stripping the square brackets out too.

Viewing 15 replies - 1 through 15 (of 21 total)
  • The topic ‘Square brackets removed from links’ is closed to new replies.