Skip to main content
added 696 characters in body
Source Link
Johansson
  • 15.4k
  • 11
  • 43
  • 79

To output your content, It is advised that you pass your content through a filter. get_the_content() does not do this, so it will not for example execute shortcodes or create <p> tags.

So, it would be better to use it this way:

<?php echo apply_filters( 'the_content', wp_trim_words( get_the_content() , 70 ) ); ?> 

You can also pass the $before and $after arguments to your title. This is a simple example of how to do so:

<?php the_title('<h1>', '</h1>'); ?>

Which will output this:

<h1>Your Title Here</h1>

It's possible to pass variables or functions too. Take a look at this example:

<?php the_title('<h1><a href="'.get_the_permalink().'">','</a></h1>'); ?>

This will create a link of your title and wrap it in a header tag:

<h1><a href="some path here">Your Title Here</a></h1>

You might want to take a look at this codex page for additional information about the_title_attribute() too.

To output your content, It is advised that you pass your content through a filter. get_the_content() does not do this, so it will not for example execute shortcodes or create <p> tags.

So, it would be better to use it this way:

<?php echo apply_filters( 'the_content', wp_trim_words( get_the_content() , 70 ) ); ?> 

To output your content, It is advised that you pass your content through a filter. get_the_content() does not do this, so it will not for example execute shortcodes or create <p> tags.

So, it would be better to use it this way:

<?php echo apply_filters( 'the_content', wp_trim_words( get_the_content() , 70 ) ); ?> 

You can also pass the $before and $after arguments to your title. This is a simple example of how to do so:

<?php the_title('<h1>', '</h1>'); ?>

Which will output this:

<h1>Your Title Here</h1>

It's possible to pass variables or functions too. Take a look at this example:

<?php the_title('<h1><a href="'.get_the_permalink().'">','</a></h1>'); ?>

This will create a link of your title and wrap it in a header tag:

<h1><a href="some path here">Your Title Here</a></h1>

You might want to take a look at this codex page for additional information about the_title_attribute() too.

Source Link
Johansson
  • 15.4k
  • 11
  • 43
  • 79

To output your content, It is advised that you pass your content through a filter. get_the_content() does not do this, so it will not for example execute shortcodes or create <p> tags.

So, it would be better to use it this way:

<?php echo apply_filters( 'the_content', wp_trim_words( get_the_content() , 70 ) ); ?>