When I remove breadcrumbs the_content is not showing


Hi,

I have a custom post type "agents". On the single.php the_content() is not showing when i remove the breadcrumbs:

All other fields like the_title() and custom fields are showing. Only the_content() not.

When I remove the single.php file from my child theme the_content() is showing.

Is use this in my single.php

beans_modify_action_callback( 'beans_loop_template', 'show_agent_content' );

function show_agent_content() {
  // My content.
}

Hey Bas,

This is because your are actually replacing the loop and therefore the post data isn't set. You should eighter set a standard WP while ( have_posts() ) : the_post(); loop or since it is a single view, you could just the set the post data as below:

beans_modify_action_callback( 'beans_loop_template', 'show_agent_content' );

function show_agent_content() {

  setup_postdata( get_post() );

   the_content();

  wp_reset_postdata();

}

Thanks, it is working.

Write a reply

Login or register to write a reply, it's free!