• 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 ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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! ?? )

    Thread Starter venkmanuk

    (@venkmanuk)

    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' ) ) {

    ??

    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!! ??

    https://php.net/manual/en/language.types.string.php

    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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Apostrophe in Page title & php’ is closed to new replies.