WordPress.org

Ready to get started?Download WordPress

Forums

$wp_title help - conditional problem (8 posts)

  1. saganaki
    Member
    Posted 5 years ago #

    Hi

    I'm writing a template that applies to several pages. The idea is to perform different actions based on the value of wp_title('',false).

    But I'm stuck because I can't seem to compare the page name generated by wp_title with other strings

    Code:

    <?php
    $pagetitle = wp_title('', false);
    if ($pagetitle == "About") :
    ?>
    etc
    <?php endif; ?>

    I'm actually using a switch statement but the problem is the exactly the same in if.

    The only thing I can think of is that perhaps the value returned in $pagetitle is not really a text string? (Although I can echo it as one perfectly well!) If it isn't text, is there a way of converting it into text?

    Thanks!

  2. saganaki
    Member
    Posted 5 years ago #

    bump

  3. saganaki
    Member
    Posted 5 years ago #

    bump - third time's the charm?

  4. saganaki
    Member
    Posted 5 years ago #

    Pretty quiet. Have I've offended the forum rules somehow - please let me know!

  5. themeseo
    Member
    Posted 5 years ago #

    Hi Saganaki,

    Thank you for your code, I modifies is

    <?= wp_title('', false); ?>

    you can replace in <title><?= wp_title('', false); ?></title> on header.php

    Sekr.

  6. saganaki
    Member
    Posted 5 years ago #

    Hi Sekr

    Thanks for the response. Not sure I really understand. Trying to get wp_title('',false); to return a value that can be compared against another string.

    Tks

  7. funkboybilly
    Member
    Posted 5 years ago #

    Trying to output wp_title(); to string also for a variable use in query_posts();

  8. ThinkArchimedes
    Member
    Posted 5 years ago #

    Did you ever solve this problem? I am experiencing the same difficulty now. Much thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags