Pushing Category and Publish Date to Google Analytics

If you’re printing your script inline (i.e. not in an external file), you can use PHP to dynamically output the JavaScript argument: <script> _gaq.push( ‘setCustomVar’, 3, ‘pubDate’, ‘<?php the_time( ‘Ym’ ) ?>’, 3 ); </script> See the PHP manual for date arguments, which will explain why I’ve used Ym.

Easy reading or transfer of data from posts?

do_shortcode([espro-slider id=21]) will process the shortcode and return the result. The Codex describes exactly this example: // Use shortcode in a PHP file (outside the post editor). echo do_shortcode( ” ); You can often just call the callback directly also: function generic_shortcode_callback($atts,$content) { return “Yay! “.$content; } echo generic_shortcode_callback(”,’ Me!’); VS: function generic_shortcode_callback($atts,$content) { return … Read more

Dynamically adding filters

I think you are on the right track, but that last part is messy. You are using the bw_add_markup_class function for two different purposes : to return the classes that you want to add to list the context of the filters that you want to call If I understand well want you are trying to … Read more

how can I include some custom variable from functions.php?

WordPress theme files are called thru functions/classes, so variables declared in functions.php are not recognized by other theme files, until you specify you want to use the global value of the variable. Do so like this in your theme template files: global $mysite_address_url; you can then use $mysite_address_url as you’d like. To read more about … Read more

echo var into wp_query

The “cat” variable need to be an ID of the category. It depends how you configured the ACF field in the backend. Maybe you should print_r($selected_cat) to see what’s inside the variable. it is probably an array with the full information of the category.

Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )

This is that classic question, do you have 6 eggs or half a dozen, and frankly, it doesn’t actually matter. It is however better to use get_comments_number() because the post object is retrieved from the $GLOBALS[‘post’] global which is set by the_post() inside the loop the post object is validated through WP_Post (through get_post()) the … Read more

WordPress custom widget undefined variable notice

You can you wp_parse_args to merge $instance with a default array. So, you would start you form function not with extract($instance) but with $defaults = array( ‘title’ => ‘Your title’, ‘text’ => ‘…’, ‘image_url’ => ‘…’ ‘textarea’ => ‘…’ ); $instance = wp_parse_args((array) $instance, $defaults);

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