Shortcode result appears above page content

You should use output control functions if you want to do it this way: function cotizador_shortcode($atts) { … your code here … ob_start(); ?> <!– THE CODE BELOW SHOULD APPEAR IN THE PAGE CONTENT AS A TABLE –> … HTML here … <?php $output = ob_get_contents(); ob_end_clean(); return $output; } add_shortcode(‘cotizador’, ‘cotizador_shortcode’);

how to add shortcode widget at end of main blog page

I would suggest using do_shortcode as mozboz suggested. But I think that using the single.php file is a better way of doing it. The template you should use will depend on how your theme is structured, but if the element is supposed to always display after a post then editing the main template is the … Read more

JS working when used normally but not in wordpress

Solved. The problem was that mojs has to be included between the <body></body> tags, and the wp_enqueue_script() function that enqueued mojs needed an empty string as argument just before the ‘true’ parameter (I forgot to specify that there was no required version number of that script). So, changing wp_enqueue_script(‘mojs’, ‘https://cdn.jsdelivr.net/mojs/latest/mo.min.js’, array(‘jquery’), true); wp_enqueue_script(‘favjs’, $favbtnscript, array(‘jquery’, … Read more

How to display total user count by specific role in WordPress as statistics?

insert this code in your theme functions.php and use this shortcode [users_count_bro] to display where you want function total_count_bro() { $out=””; $user_count_data = count_users(); $avail_roles = $user_count_data[‘avail_roles’]; foreach ( $avail_roles as $role_key => $role_count ) { $out .= $role_key.’:’.$role_count.'<br/>’; } return $out; } add_shortcode( ‘users_count_bro’, ‘total_count_bro’ );

How to display content if user meta data isn’t empty with shortcode

Your shortcode can look like this: [check-if-empty usermeta=”last_name”] Is not empty [/check-if-empty] The parameter called “usermeta” is added to your function ($atts) and it’s value is used to check the userdata. function func_check_if_empty( $atts, $content = null ) { if ( is_user_logged_in() ) { /* check if logged in */ $user_meta = $atts[‘usermeta’]; /* get … Read more