How can I fix those issues generated by the Themecheck plugin

Registering custom posts is a plugin territory. It means that you need to remove them from the theme’s functionality and register them via a plugin (usually recommended when installing the theme using TGM Plugin Activation or something else). Here are the recommendations of the Theme Review Team. Themes must not incorporate the following, Plugin-territory functionality. … Read more

Get post id shortcode

Place the below code to your themes functions.php or inside your plugin and the [return_post_id] shortcode will print the post ID. add_shortcode( ‘return_post_id’, ‘the_dramatist_return_post_id’ ); function the_dramatist_return_post_id() { return get_the_ID(); } Hope that helps.

Retrieve multiple values passed to a single attribute in a shortcode

The solution below will parse the comma separated values passed to the shortcode’s type parameter. We’ll also strip out any whitespace surrounding the values which is a usability improvement (see example 2 after the code below). add_shortcode( ‘related’, ‘wpse_related’ ); function wpse_related( $atts, $content=”” ) { // User provided values are stored in $atts. // … Read more

Add new “Insert Into Post” button with another function

There’s a get_image_send_to_editor() function in wp-admin/includes/media.php that runs this: apply_filters( ‘image_send_to_editor’, $html, $id, $caption, $title, $align, $url, $size, $alt );. Try hooking that filter. Edit: Help with the filter call… Your call to hook the callback would look like this: add_filter(‘image_send_to_editor’, array(&$MyClassReference, ‘filter_iste’), 10, 8); The 10 is the priority, you might need to adjust … Read more

Extract attribute values from every shortcode in post

Method #1 If available, I would use the: shortcode_atts_{$shortcode} filter to collect the attributes of a given shortcode. Example: $text=” “; $out = wpse172275_get_all_attributes( ‘gallery’, $text ); print_r( $out ); with the output: Array ( [0] => [1] => Array ( [ids] => 1,2 https://wordpress.stackexchange.com/questions/172275/extract-attribute-values-from-every-shortcode-in-post => file ) [2] => Array ( [ids] => 3 … Read more

Are php template shortcodes ok?

Is it Ok? Yes! Is it Optimal? No What Would Be Better? Shortcodes map on to PHP functions, so why not cut out the middle man and go straight to the original function? Are there any other downsides? Yes! That shortcode had to come from somewhere, now you have a dependency, maybe the plugin that … Read more

Display sorting options dropdown when using WooCommerce product category shortcode

Since WooCommerce 3.2, Woocommerce shortcodes and their available attributes have changed. So try the following shortcode instead (for “foo” product category): [product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”] or inside php code: echo do_shortcode( ‘[product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”]’ ); Now you will see that the sorting options dropdown appear. Note: orderby argument with an empty value … Read more