Help Desk

Call the title

  • | Permalink

    I’m trying to call the title as a link title (” href=”…”> on my single-event.php. When I use <?php echo get_the_title(); ?>, it shows the code rather than the event title.

    What else can I do to achieve this task?

    Posts: 404
    | Permalink

    Hi Hunter Wilson,

    Thanks for coming here to the forums, I want to help you on your issue, but to do so I will need to see the full code of your <b>single-event.php</b>.

    Other than that the default HTML for a link with the post title would be:

    <a href="<?php echo get_permalink(); ?>"><?php the_title(); ?></a>
    

    My Best regards,

    | Permalink

    I tried what you provided and still got the code showing rather than the current event page title. The code I originally posted turned into a link, but it looks like this:

    < a href=”‘ . get_field(‘instagram’) . ‘” target=”_blank” >

    Posts: 404
    | Permalink

    Hi Hunter,  the code you provided should be as the following:

    <?php echo '<a href="' . get_field( 'instagram' ) . '" target="_blank">'  . get_the_title() . '</a>'; ?>
    

    Check if the code above resolves your issue, if not I will help you faster if you provide me the full file, via http://codebin.org/

    My Best Regards,

    | Permalink

    I got an error when I tried that. Here is my paste bin code for a link: http://codebin.org/view/18b7694f

    Posts: 404
    | Permalink

    Can you send me which error happened?

    Thanks,

    | Permalink

    I think I had some incorrect syntax, but no matter what I try I can’t get it to display the title. Can you provide me the revised snippet of my code you recommend I try and share it via pastebin?

    | Permalink

    I’m fairly familiar with PHP and my events used to be able to call the title all over my event pages, but I’m not sure what caused this to change.

    Posts: 404
    | Permalink

    Hi Hunter,

    There you go: http://pastebin.com/N6qYmWjV

    If there is any problems again, please send me the error so I can help you debug whats happening.

    My Best Regards,

    Posts: 65
    | Permalink

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.