How can I make a shortcode from this code?

It should be as simple as this: function item_count() { $dir=”/PATH TO DIRECTORY/”; $filecount = 0; $d = dir( $dir ); while ( $f = $d->read() ) { if ( ( $f!= “.” ) && ( $f!= “..” ) ) { if( ! is_dir( $f ) ) { $filecount++; } } } return ‘(‘ . … Read more

shortcodes between square and curly brackets

To WordPress, as it parses through the content, only the tags using square brackets will be treated as short codes. The curly bracket example given would not be parsed by the WordPress core. It is possible the tag would be parsed by a plugin or theme if they are looking for hooks in the content … Read more

Stop parsing shortcodes

The correct way is calling remove_filter with the same priority as the hook was added: remove_filter( ‘the_content’, ‘do_shortcode’, 11 ); Some plugins change this filter’s priority, so you could clear the global list of registered shortcodes temporary: add_filter( ‘the_content’, ‘toggle_shortcodes’, -1 ); add_filter( ‘the_content’, ‘toggle_shortcodes’, PHP_INT_MAX ); function toggle_shortcodes( $content ) { static $original_shortcodes = … Read more

sql query in shortcode not working

I have worked it out and here are the steps to what I did to get it working created a custom table in the wordpress database (called it wp-products) this table had the following fields: id, make, model, price Created a shortcode to retrieve the price. Shortcode looks like this [product_price id=2] where id=2 is … Read more

Passing attributes to shortcode dynamically

Not quite like that, but you can achieve the same result if you use a pre-defined value or argument in your shortcode to act as a “flag”: [authoorsposts author=”post”] …then in your handler: function wpse_209684_author( $atts ) { if ( ! empty( $atts[‘author’] ) ) { $author = $atts[‘author’]; if ( $author === ‘post’ ) … Read more

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