Do not show child pages of child pages

You can do that with using the depth argument. I also created an array of your arguments for better readability. The depth argument accepts the following parameters: ‘depth’ (int) Number of levels in the hierarchy of pages to include in the generated list. Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and … Read more

Get Shortcode Attributes

I figured it out. With the shortcode set as [camp_posts type=”academic, sports”] the code that does the trick is this: function camp_posts_function($atts) {//Creates shortcode [camp_posts type=”academics, sports”] $atts=shortcode_atts( array( ‘type’ => ‘nothing’, ), $atts, ‘camp_posts’); $ShortcodeAtts=esc_attr($atts[‘type’]);//Puts “type” attribute into a variable $ShortcodeAttsArray = explode(‘,’, $ShortcodeAtts); $IDout = array();//Initializes array foreach($ShortcodeAttsArray as $slug) { array_push($IDout, get_category_by_slug($slug)->term_id);//Gets … Read more

Adding Image Count to Multigallery

You can try function multi_gallery_shortcode($atts, $content=null) { extract( shortcode_atts( array( ‘pid’ => 0, ), $atts ) ); //format input $pid = intval($pid); // construct a post object dependent on the input value if($pid>0){ // query a post object $pobj = get_post( $pid ); }else{ global $post; // current post object $pobj = &$post; } // … Read more

Shortcode with product catgory counter

Try this: (add it to the theme’s main functions.php file) add_shortcode( ‘products-counter’, ‘products_counter’ ); function products_counter( $atts ) { $atts = shortcode_atts( [ ‘category’ => ”, ], $atts ); $taxonomy = ‘product_cat’; if ( is_numeric( $atts[‘category’] ) ) { $cat = get_term( $atts[‘category’], $taxonomy ); } else { $cat = get_term_by( ‘slug’, $atts[‘category’], $taxonomy ); … Read more

Some doubts about gallery shortcode in WordPress

If you want to display the attached image gallery, from another post, you can use: where the custom id attribute is the post ID. If you want limit the number of items in a gallery, there seems to be a plugin available on wordpress.org called Limit parameter for gallery shortcode (no affiliation). It uses the … Read more

Creating a WordPress shortcode

Separate out your logic from the string you want to return: <?php // Adding a shortcode to return each author’s social media links function funcauthor_social( $atts ){ $meta_socialgr = esc_url(get_post_meta( $post->ID, ‘author_goodreads’, true )); $output=”<div class=”authorsocial”><h5>Connect, Share &amp; Follow</h5><ul>”; if (!empty($meta_socialgr)) { $output .= ‘<li><a href=”‘.$meta_socialgr.'”><img src=”http://fiddlehead.milkbossindustries.com/files/goodreads.jpg”></a></li>’; } $output .= ‘</ul></div>’; return $output; } add_shortcode( … Read more