extract shortcodes from string

Where is this string located ? I know you wrote “without wordpress system” , but WordPress has a function get shortcode regex If you really want to avoid it for some reason, the following example might help you : // check the post for a short code function check_shortcode( $shortcode = NULL ) { $post_to_check … Read more

How to enqueue script based on post category?

Inside your theme’s functions.php add something like this: function my_conditional_enqueue_script() { global $post; if (is_single($post->ID) && in_category(‘mouse’, $post->ID)) { wp_enqueue_script(‘mousescript’); } } add_action(‘wp_enqueue_scripts’, ‘my_conditional_enqueue_script’); Also, make sure you use wp_register_script before you attempt to enqueue.

How navigation works in custom loop within shortcode?

if you look at previous_posts_link() and next_posts_link() in source, you’ll see why they don’t work, they use the global $paged and $wp_query vars to format the links and determine whether or not they appear. you’ll have to roll your own pagination using the paged and max_num_pages vars in your custom query.

Turn a snippet of HTML and PHP into a shortcode

When you want to turn a snippet into a shortcode, you have to return a string. You cannot use echo or print anything in any other way. Also, always escape your data, and check if there are actually values. I have used the HEREDOC syntax here, because it is easy to read: add_shortcode( ‘taobao’, ‘taobao_shortcode’ … Read more

Shortcode to insert menu in page body?

That code should work. Are you usign “myclass” as the class and not “.myclass”? Is this for a specific use where class will always be the same? If you’re only looking to ever use this on one place, you can do this: function print_menu_shortcode($atts, $content = null) { extract(shortcode_atts(array( ‘name’ => null, ‘class’ => null … Read more

How to display the comment_form with a shortcode while removing it from its default position?

Version #1 The following seems to work for the Twenty Fifteen theme: /** * Display the comment form via shortcode on singular pages * Remove the default comment form. * Hide the unwanted “Comments are closed” message with CSS. * * @see http://wordpress.stackexchange.com/a/177289/26350 */ add_shortcode( ‘wpse_comment_form’, function( $atts = array(), $content=”” ) { if( is_singular() … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)