Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problems echoing 'the title' plus something else

Featured Replies

In my theme, if I use this code:

echo '<h3 class="posttitle">' . the_title() . '</h3>';

What I get is:

The title
<h3 class="posttitle"></h3>

What I was expecting:

<h3 class="posttitle">The title</h3>

Also, similar problem here:

else if ( in_category( 'reviews' ) )	{
	echo 'Latest review: ' . the_title();
}

This displays the wrong way around. So, 'The title Latest review:' rather than 'Latest review: The title'

 

Any ideas?

Asuming you are talking about WordPress, you don't need echo. The the_title() method has the "echoing" build in. Also make sure you call the method from within the loop:

<?php
  // Start the Loop.
    while ( have_posts() ) : the_post();
?>
<h3><?php the_title() ?></h3>
<!--You get the content the same way-->
<div><?php the_content() ?></div>

<?php
    endwhile; 
    //the loop ends here. You can not call the methods outside the loop
?>

Edited by Nillervision

  • Author

 

The the_title() method has the "echoing" build in.

 

Oh! Well, that explains it. Thanks, Nillervision :)

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.