Only first shortcode gets executed

As indicated in the comments this code has nothing to do with shortcodes in the WordPress sense, but it is easy to see why it will never evaluate more than one pattern. preg_match returns true if there is at least one instance of the needle found in the haystack. So, no matter how many “shortcodes” … Read more

Excecuting php function in shortcode

This will probably not work, or work in unexpected way. Shortcodes should probably be displayed only on a “post” single page. Using a shortcode in the way you want will either make the breadcrumbs not to be displayed on archive pages or have them displayed there multiple times or wrong places. What you should do … Read more

Plugin PHP file gives error 500 [closed]

The 500 Internal Server Error is a very general HTTP status code that means something has gone wrong on the web site’s server. You have to enable the debug true to understand what is the problem. Open the wp-config.php file. To enable debugging mode, change define(‘WP_DEBUG’, false); line to the define(‘WP_DEBUG’, true); in wp-config.php file. … Read more

Remove the last X characters of a custom field value

You have to consider that you’re dealing with substr() a string related function as the str in the function name indicates. That does mean that the parameter $string you give actually has to be of the type string. get_post_meta() on the other hand does just give you back whatever type you saved in the first … Read more

Display most popular posts of category

How about adding ‘cat’=> 10 to your query? $new_query = new WP_Query( array( ‘posts_per_page’ => $carousel_count, ‘meta_key’ => ‘wpb_post_views_count’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘monthnum’=> $month, ‘year’=> $year, ‘cat’=> 10 ));