Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMaja B.
12,984 Pointsthe_content()
Hi, anyone knows how to display the_content() but without beeing wrapped into p tags.
I've tried this
<?php echo get_the_content(); ?>
but it does not work.
1 Answer
Andrew Shook
31,709 PointsMaja, you almost had it. The correct function is get_content(), this will return the value as just a string.
Maja B.
12,984 PointsMaja B.
12,984 PointsHi, thanks but how?
Both
<?php get_content(); ?>
and
<?php echo get_content(); ?>
give: Fatal error: Call to undefined function get_content() in C:\xampp\htdocs\ajp\wp-content\themes\pho-child\content-commercial-art.php on line 10
Maja B.
12,984 PointsMaja B.
12,984 PointsOne more think (because I'm not sure that my initial question was clear enough)
The problem with
<?php echo get_the_content(); ?>
is that it writes/echoes:
<p>My content</p>
instead of just bare string - as I would like it to echo:
My content
So can you help me display the content without p tags?
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsSorry, yes it is get_the_content(), and if you are still getting "p" tags then those are being put in by the wysiwyg editor. In that case try this:
Maja B.
12,984 PointsMaja B.
12,984 PointsHi, yes, this works! Great!