• Resolved Taras Dashkevych

    (@taskotr)


    Hi,

    I am trying to get the title of the event in single page view using the get_the_title() function. As a result, I am getting an empty string.

    The theme uses index.php to display the site pages. Here is an example of that default template file:

    
    if ( have_posts() ) :
        while ( have_posts() ) : the_post();
    
    	var_dump( get_the_title() );
    
        endwhile;
    endif;
    

    Any ideas why this core function does not work as intended?

    Thank you,
    Taras

Viewing 1 replies (of 1 total)
  • Santiago

    (@sjaure)

    Hi @taskotr
    I don’t know why the code doesn’t work, but I’d first make sure $post->ID exists.

    Once you are sure about that, then do $title=get_the_title($post->ID)
    Then see what’s inside $title.
    It might sound obvious but it will help you finding where the issue comes from.

    Let me know how it goes

    Best
    Santiago

Viewing 1 replies (of 1 total)
  • The topic ‘Using get_the_title() in the main loop’ is closed to new replies.