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

Catch own Exceptions

Your exception isn’t caught by the try{} catch(){} block, because it isn’t thrown inside the try catch block. This demonstrates a lack of understanding of asynchronous events and the WordPress hook/action/event system. The methods of your object are attached to the init action hook, and are thrown when the init hook is fired, not when … Read more

Multiple Parameters for a Shortcode

Lets look at the shortcode [SH_TEST var1=”somevalue” var2=”someothervalue”]THE SHORTCODE CONTENT[/SH_TEST] the shortcode handler function accepts 3 paramters $atts – an array of attributes passed by the shortcode in our case: $atts[‘var1’] is set to ‘somevalue’ $atts[‘var2’] is set to ‘someothervalue’ $content – is a string of the value enclosed with in the shortcode tags, in … Read more

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