Apostrophe in Page title & php (4 posts)

  1. venkmanuk
    Posted 3 years ago #

    Hi there,

    hopefully there's a just a quick answer to this. I have a Page called Let's Talk that needs to have an apostrophe in it.

    i'm using an if statement to check what page we're on.
    if ( is_page( 'check' ) ) { works fine.. but
    if ( is_page( 'let's talk' ) ) { doesn't - because of the apostrophe of course.

    what do i need to do to sort it?
    thanks :)

  2. Rev. Voodoo
    Posted 3 years ago #

    I'm no expert.. but .. does escaping it work?

    if ( is_page( 'let\'s talk' ) )

    (OTherwise could always just use the ID and bypass the problem altogether! ;) )

  3. venkmanuk
    Posted 3 years ago #

    thanks Rev. Voodoo !

    it didn't work --> but it's nice to know i only need one \ to escape it.. i thought i needed two for some reason!?

    anyhooo it works if i put the permalink in there, so i'm just using.
    if ( is_page( 'talk' ) ) {


  4. Rev. Voodoo
    Posted 3 years ago #

    I'm no php expert... I believe you would use 2 \\ to escape a literal backslash....

    like in an echo you would need to \\ to output \

    I'll let the real experts back up my feeble guesses!! ;)


    If you run into any further problems with these conditionals, it can often be fixed by simply using the page ID. The number associated with it. That will always work!! But it seems you have things working, so that is good!

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.