The WordPress function the_title() is showing blank

Related searches

I am using this code to display a post on my homepage. <?php the_title(); ?> is returning blank.

Source: idolizeonline.com (NSFW link)

-- If you hover over the thumbnails, the title and excerpt of the post should appear over the image (excerpt is title is not).

<?php if(!of_get_option('ttrust_open_project_single')) : ?>

    <div class="project small ajx <?php echo $p; ?>" id="project-<?php echo $post->post_name;?>">
        <a href="<?php the_permalink() ?>" rel="bookmark" ></a>

        <a href="#<?php echo $post->post_name; ?>" ><?php the_post_thumbnail($project_thumb_size, array('class' => 'thumb', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?></a>
        <span class="title">
            <div>
                <span id="theTitle"><?php the_title(); ?></span>
                <span id="theExcerpt"><?php the_excerpt(); ?></span>
            </div>
        </span>
    </div>

<?php else: ?>

    <div class="project small <?php echo $p; ?>" id="project-<?php echo $post->post_name;?>">
        <a href="<?php the_permalink() ?>" rel="bookmark" ></a>

        <a href="<?php the_permalink() ?>" ><?php the_post_thumbnail($project_thumb_size, array('class' => 'thumb', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?></a>
        <span class="title">
            <div>
                <span id="theTitle"><?php the_title(); ?></span>
                <span id="theExcerpt"><?php the_excerpt() ?></span>
            </div>
        </span>
    </div>
<?php endif; ?>

Put the following code at the top of your file:

<?php if( have_posts() ) the_post(); ?>

See: The Loop

Is there a way to conditionally check whether a WordPress post title , You can add the before and after html tags to the_title() function. If the post_title is empty, nothing will be outputted. the_title('<h1>', '</h1>');. <?php the_title(); ?> is returning blank. Source: idolizeonline.com ( NSFW link) -- If you hover over the thumbnails, the title and excerpt of the post should appear over the image (excerpt is title is not).

I am still unsure what exactly was the issue, but replacing the_title(); with <?php echo $post->post_title; ?> worked fine.

Use the_title() and the_title_attribute() Correctly, WordPress provides a nice little function for displaying the title of the current post: the_title(). This function gets used all over the place: in the� Yes, if you would like to use a blank WordPress theme, also known as a Starter theme, you can use the Underscores theme (_s) from Automattic. Conclusion: common issues typically cause a WordPress blank page. Although it is extremely frustrating, finding and fixing the WordPress blank page is not as difficult as it may look.

Check your page.php file. Do you have all these things included in that file?

global $post;global $wpdb;
// Your header goes here

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="your_main_div_to_display_content">
// Your title goes here
<?php the_title();?>
</div>
<?php endwhile; endif; ?>

// Your footer goes here

Blank page when click on “category”, Hi When I click on advert category I am redirected to a blank page For instance, you Shows the loop content */ function wp_portfolio_theloop() { if( is_page() )� This function displays or returns the unescaped title of the current post. This tag may only be used within The Loop, to get the title of a post outside of the loop use get_the_title. If the post is protected or private, this will be noted by the words “Protected: ” or “Private: ” prepended to the title. Security considerations

I had same issue, and in my case I was using $post for another purpose, which was conflicting and causing the_title() to display blank.

the_title() | Function, Display or retrieve the current post title with optional markup. Like the_content() , the output of the_title() is unescaped. This is considered a� If the wordpress widget title is blank or empty, then don't display the $before_title and $after_title wrapping the title. Right now if the title is empty, you can end up with. If there are margins set for h2.widgettitle then you end up with blank space.

I recently ran into this issue while developing a WordPress theme. WordPress has some declared variables being declared globally, like $post, $posts, Post and so on, if you are coding a WordPress plugin or theme, you need to make sure you treat those variable names like a reserved word. This is one of the errors you can encounter if you don't.

Wordpress the_title(); is showing blank, I had same issue, and in my case I was using $post for other purpose which was conflicting and causing the_title() to display blank. The easiest way to hide page or post title is by leaving the title field blank. However, this option is not recommended. WordPress will generate its own permalink when there’s no title, and it’ll be hard to identify untitled pages and posts. For that reason, we recommend using plugins like Title Remover and Hide Page and Post Title.

By default, after creating and publishing a page, WordPress will display its title on the front-end. Note that I’m not referring to the page titles that appear in the browser tab (<title>), but those that appear on your page as headings, preferably H1s (<h1>), if you want to keep up with the best SEO practices.

If you’re using the classic WordPress editor, then sometimes buttons from the visual editor may disappear or start showing blank white spaces instead of buttons. This problem may occur when concatenated JavaScript is not working.

thanx, that works for the space above the title, but not for below. In fact, changing the parameter in padding-bottom doesn’t change anything I think. Any solution for the whitespace below the page title and the text? PS: I use a child-theme, yes And do the changes made in the customizer>extra css stay when you update twenty-seventeen?

Comments
  • Does the call to the_exerpt() work?
  • Did you try get_the_title ? Does that return anything? Look at this : codex.wordpress.org/Template_Tags/the_title
  • @andrewsi, it's the_excerpt().
  • @SpencerCameron - this is what happens when I'm under-caffeinated. Though I'd still like to know if it works :)
  • I figured it was a typo. :) I don't think it will, though. His template is missing an integral piece needed by the template tag system. See my answer below.
  • I added this above <?php if(!of_get_option('ttrust_open_project_single')) : ?> and it didn't work
  • Perhaps there is no valid post to display? Put this at the top of your file temporarily: <?php if( ! have_posts() ) echo 'No valid posts'; ?> If you see No valid posts output, you've got other problems.
  • I added the code, it didn't apear. I'm lost as to why the_excerpt() works and not the_title()
  • What if it is a 'page', not a 'post'?
  • What if it is WordPress 'pages' (static), not WordPress 'posts' (blog posts)?
  • What purpose? Form submit?