WP Query Loop


Hi Joshua,

If you are going to user lots of custom HTML including custom meta, the easiest my be to replace the main loop with your own custom loop and HTML, here is an example snippet:

beans_modify_action_callback( 'beans_loop_template', 'example_content' );
/**
 * Page content.
 */
function example_content() {
 // Set your query.
  $query = new WP_Query( array(
   'post_type' => 'my_photos',
   // ...
  ) );

  while ( $query->have_posts() ) : $query->the_post();
    ?><!-- Post HTML --><?php
 endwhile;

 wp_reset_postdata();
}

If you want to keep the original, I would advise to change the main query using the pre_get_posts action and then inject your post meta using Beans HTML API actions ;-)

Happy coding,


Thank you, Thierry, that is what I needed.

Write a reply

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