Title: Shortcode breaks Plugin
Last modified: October 6, 2018

---

# Shortcode breaks Plugin

 *  Resolved [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/shortcode-breaks-plugin/)
 * Hi there,
 * the Plugin works great an all my pages, except for the pages where I added a 
   simple function via shortcode. The widgets just don’t show up. If I change the
   shortcode (“_get_special_posts”) the Widgets do appear.
 * The shortcode is this:
 * [get_special_posts cat=1 anz=3]
 * and in functions.php I have this:
 *     ```
       function get_special_posts_function($atts) {
       	$a = shortcode_atts( array(
               'cat' => '1',
               'anz' => 5
           ), $atts );
       	query_posts('cat='.$a['cat'].'&showposts='.$a['anz']);
   
       	echo $header;
                       if (have_posts()) : while (have_posts()) :
   
                        the_post();
                        $t = get_the_title();
   
                        echo "<h3>".$t."<h3>";
   
                   endwhile;
               endif;
               }
   
       add_shortcode( 'get_special_posts', 'get_special_posts_function' );  
       ```
   
 * What is wrong here? How can I fix this?
 * Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/shortcode-breaks-plugin/#post-10755649)
 * I should add that WP and the Plugin are installed with the latest versions, and
   the Template is TwentySixteen.
 *  Thread Starter [Gerdski](https://wordpress.org/support/users/gerdski/)
 * (@gerdski)
 * [7 years, 7 months ago](https://wordpress.org/support/topic/shortcode-breaks-plugin/#post-10755698)
 * OK, I solved it. It was my fault.
 * “query_posts” was not the best way to get the posts in my function, because it
   interfered with The Loop.
 * Now I use “get_posts” instead, the content is returned in a different way (have
   to use nl2br), but it all works fine now.
 * Resolved 🙂

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Shortcode breaks Plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-page-widget_fcfbfc.svg)
 * [WP Page Widget](https://wordpress.org/plugins/wp-page-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-page-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-page-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-page-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-page-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-page-widget/reviews/)

## Tags

 * [function](https://wordpress.org/support/topic-tag/function/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * 2 replies
 * 1 participant
 * Last reply from: [Gerdski](https://wordpress.org/support/users/gerdski/)
 * Last activity: [7 years, 7 months ago](https://wordpress.org/support/topic/shortcode-breaks-plugin/#post-10755698)
 * Status: resolved