Substite Category Slug in a Shortcode

Try this: <?php echo do_shortcode(‘[category_post_count category=’.$css_slug.’]’); ?> I’m not sure what you’re trying to do though? If you’re not doing this in actual content pages, you don’t need the shortcode. You could just do it all within the php page. Let me know if you need more info.

how to add shortcode in wordpress container [duplicate]

This is most likely due to the way your shortcode is constructed. PHP scripts are run on the server before (as) the HTML is generated. Try buffering your shortcode ouput like this: function my_function( $atts ) { ob_start(); // do some stuff $code_output = ob_get_contents(); ob_end_clean(); return $code_output; } More info: https://secure.php.net/manual/en/book.outcontrol.php

Position shortcode off [duplicate]

Please try with this- /* * * Shortcode to display Post as links on Profile Pages * */ function imwz_golfs_list_function( $atts ) { if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array(‘posts_per_page’ => ‘-1′,’author’ => $current_user->ID); $author_posts = new WP_Query($author_query); ob_start(); if($author_posts->have_posts()) : echo ‘<ul>’; while($author_posts->have_posts()) : $author_posts->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/295515/<?php the_permalink(); ?>” title=”<?php … Read more

How can I list only custom shortcodes?

The linked question shows you how to get all the shortcode tags in an array. So narrowing them down to specific ones is purely a PHP question. But the answer’s simple enough. Use array_filter() on the array of tags with a callback function that uses strpos() to see if each tag contains the work you’re … Read more

redirect if shortcode exists

If you look at the source code of add_shortcode you will see this function doing little more than store the name of the shortcode in a global array. So, checking if a shortcode exists means looking it up in the array. Hence, if you want to check for a specific shortcode in the_content you must … Read more

Short code inside the page not working in WordPress

Without knowing further details of your specific installation: Make sure you are actually previewing live on the web in a browser to see if the short-code actually is working. Make sure you have spelled the short-code correctly, and have the correct syntax. (See theme’s documentation.) If the short-code requires some special JavaScript library, often other … Read more

Can I use shortcodes in mail body

The shortcode generation should output a string, so that should in theory be possible if you know and trust the shortcode’s output. But many shortcodes are generated with the front-end in mind and within the loop context, so the mail context might not always work though, if they depend on conditional checks like is_single(). There … Read more