I have created a shortcode using the while loop, which is going to break the loop when used with the page builder. How to solve it. Here may custom shortcode here my showing part
I have created a shortcode using the while loop, which is going to break the loop when used with the page builder. How to solve it. Here may custom shortcode here my showing part
You don't use global $wp_query
object anywhere in your code, so there is no point in calling wp_reset_query()
.
On the other hand, you do use global $post
variable, so after your code you should restore it's original value with wp_reset_postdata();
.
So change wp_reset_query()
to wp_reset_postdata()
and it should be OK.
Shortcodes should return their values and they should not display anything.
So you can't use the_title()
inside of it - this template tags echoes its value and doesn't return anything.
You should change it to get_the_title()
.