Register visits of my pages in wordpresss

It’s not a good idea to store user’s data on a file that is publicly accessible. A better way would be to create a folder, and store your file under it. Also, it’s better to use WordPress’s filesytem class rather than directly using PHP’s built-in functions. Here’s a quick fix: function wpse381320_after_login( $atts ) { … Read more

ShortCode and extra

I discover that it’s a know bug, and will be fix in future release Reference here So then, i used this code… not pretty, but do the magic !, thanks $content = do_shortcode( shortcode_unautop( $content ) ); if ( ‘</p>’ == substr( $content, 0, 4 ) and ‘<p>’ == substr( $content, strlen( $content ) – … Read more

Are shortcode functions applied while rendering the content, or are they executed and stored with the post content?

I don’t know in what exact order filters are applied to the_content(); and whether that’s early enough, but if it doesn’t work for you, I believe it is safe to assume that you’re right in thinking that the shortcode is applied to late. From /wp-includes/shortcodes.php (line 296, wp 3.2.1) it can be seen that shortcodes … Read more

How to handle shortcodes when using the JSON API

You can add your own AJAX API for do_shortcode. Add this to a suitable location (i.e. functions.php or a plugin): add_action(‘wp_ajax_doshortcode’, ‘ajax_doshortcode’); function doshortcode() { echo do_shortcode($_POST[‘text’]); die(); // this is required to return a proper result } And this to your Javascript: $.ajax({ url : ajaxurl, data : { action : ‘doshortcode’, text : … Read more

Allow shortcode in the author bio textarea

It a matter of using do_shortcode in your author.php template file (or wherever applies). This function has to be “echoed”. And instead of using the_author_meta (which echo‘s the result), use get_the_author_meta. <?php echo do_shortcode( get_the_author_meta( ‘description’ ) ); ?>

Are .MP3 files with capital letter extensions allowed in [audio] shortcode?

No, apparently not. Until this behavior is changed in version 3.7 you can add this filter to your theme’s functions.php file to include additional extensions. Edited: I’ve updated the filter with better code suggested in the comments. Lower case and uppercase extensions function my_custom_audio_extensions( $exts ) { //merge array of upper case extensions with default … Read more

Can’t understand $atts in functions?

In general, if arguments is not used or the defaults values are to used of an argument/parameter, you don’t have to write it out, they can simply be omitted. The only time when you have to pass any value to an argument is when a function expect a valid value to be passed to it … Read more

Easy way to show excerpts of specific posts on a page

You need a couple of things. A shortcode handler, and a custom query: function wpse_186346_excerpt_length() { return 50; } function wpse_186346_excerpt( $atts ) { $atts = wp_parse_args( $atts, array( ‘posts_per_page’ => 2, // Any other default arguments ) ); // We don’t need paging, always save a query $atts[‘no_found_rows’] = true; // Create query based … Read more

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