My own shortcode show only for logged in user not public
-
I have shortcode which I can see only logged in, no public. Everything else works fine with public. Can someone advice me how to enable this in public?
My Child-theme funtions.php file and shortcode is [my-shortcode]
<?php function wpb_postsbycategory() { // the query $the_query = new WP_Query( array( 'category_name' => 'yhteystiedot', 'posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'DESC' ) ); // The Loop if ( $the_query->have_posts() ) { $string .= '<div class="postsbycategory widget_recent_entries">'; while ( $the_query->have_posts() ) { $the_query->the_post(); $string .= '<div>'.'' .get_the_content() .'</div>'; $string = apply_filters('the_content', $string); $string = str_replace(']]>', ']]>', $string); } } else { // no posts found } $string .= '</div>'; return $string; /* Restore original Post Data wp_reset_postdata();*/ } // Add a shortcode add_shortcode('my-shortcode', 'wpb_postsbycategory'); add_filter( 'widget_text', 'shortcode_unautop'); add_filter( 'widget_text', 'do_shortcode');
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘My own shortcode show only for logged in user not public’ is closed to new replies.