• Resolved Richzendy

    (@richzendy)


    Hi all,

    I have a problem, i using:

    $calendar = get_page_by_title($title, OBJECT, ‘calendario’ );

    To get a object from various posts, but if the title looks how ‘Fecha 1 – 2014’ $calendar is null, but if i do:

    $calendar = get_page_by_title(‘Fecha 1 – 2014’, OBJECT, ‘calendario’ );

    i get a object with all elements from this posts.

    To others $title formats that works, for example ‘Fecha 1 2014’, i think can be a problem with a dash i google it and i found this:

    https://wordpress.stackexchange.com/questions/100445/get-page-by-title-not-working-when-used-with-a-variable

    But html_entity_decode() don’t fix my problem.

    Any help can be appreciated.

Viewing 1 replies (of 1 total)
  • Seems to work for me. This code retrieved the page:

    $title = 'A - Z Pages By Letter';
    echo "<p>TITLE: $title</p>";
    echo '<p>HTMLENTITIES: ' . htmlentities($title) . '</p>';
    $p = get_page_by_title($title,OBJECT);
    print_r('<pre>PAGE:');print_r($p);print_r('</pre>');

    Try it on your $title and see if the two echo lines show identical titles.

Viewing 1 replies (of 1 total)
  • The topic ‘get_page_by_title does'nt work if you use title how variable and title have dash’ is closed to new replies.