Hi,

I'm using a plugin in Wordpress to display events on my page, but instead of making it simple, they are requiring me to use php to display the title of the pages as I want to.

The rest of my pages display with a little icon and then the title of the page (see here: http://dev.rjthompsonmusic.com/about). This is displayed in my themes html as follows:

<i class="icon-book"></i><?php echo wpb_page_title(); ?>

But the Events Calendar plugin uses the following php to display the title on my Tour / Single Events pages (http://dev.rjthompsonmusic.com/tour):

add_filter('tribe_get_events_title', 'my_get_events_title');
function my_get_events_title($title){
if( is_tax() ){
return $title;
}else{
return 'Tour Dates';
}
}

I want the word Tour Dates in the above code to display with a calendar icon next to it (<i class="icon-calendar"></i>) and also the $title should be returned with the calendar icon next to it as well.

How can I do this?

Many thanks for any help you can offer.

R

Recommended Answers

All 2 Replies

You can just change the function, although I'm not sure that WP will display that correctly.

I don't know if there is a specific function in Wordpress to detect URI segments, or where you can set user defined functions, but you could add a conditional statement in your template to check the current section, something like:

function get_uri_segment($int = 1, $url = false)
{
    $url = $url === false ? $_SERVER['REQUEST_URI']:$url;
    $segment = explode('/',$url);

    if(array_key_exists($int,$segment))
    {
        return $segment[$int];
    }
    return false;
}

if(get_uri_segment(1) == 'tour')
{
    echo '<i class="icon-calendar"></i> '. wpb_page_title();
}
else
{
    echo '<i class="icon-book"></i> '. wpb_page_title();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.