How Do I create a shortcode to dispaly a go to top button on any page or post

Hi You can use this below code in your function.php add_action( ‘init’, ‘register_shortcodes’); function register_shortcodes(){ add_shortcode(‘go-to-top’, ‘gtp_function’); } function gtp_function($atts) { extract(shortcode_atts(array( ‘text’ => ‘<i class=”fa fa-arrow-circle-up fa-3″></i>’, ‘speed’=>500, ‘bottom’=>20, ‘right’=> 20 ), $atts)); ?> <script> $ = jQuery.noConflict(); (function($){ $.fn.addScrollToTopButton = function(options){ var $t = $(this); var settings = $.extend({ text : “<a href=”#” … Read more

PHP error in shortcode [closed]

You are not using proper syntax, so you are likely getting a syntax error. You are using some strange sign in your code where you should be using a single quote (‘). Also, use curly brackets to enclose a condition. It is easier to debug <?php if(function_exists(‘wooslider’)){ echo do_shortcode(‘[wooslider slider_type=”posts” limit=”3″ link_title=”true” layout=”text-bottom” overlay=”full” category=”homepage-feature-post”]’); … Read more

Shortcode – Display inline icon before text [closed]

Your shortcode is not echoing the html in the right way. You have <span class=”icon”> <img …> </span> <span class=”text”> <span class=”title”> … </span> <span class=”description”> … </span> </span> In this way you cannot put icon and title inline. You need: <span class=”icon-title”> <img …> <span class=”title”> … </span> </span> <span class=”description”> … </span> This … Read more

create shortcodes for posts

Your shortcode name and shotrcode_function_name are dynamic i.e vary with post name, which cause problem if you have same post title for two post. Also, you may not know or may be confused what shortcodes are available. I recommend to do this if your post title will always be unique. while ($query->have_posts()) { $query->the_post(); $shortcodename … Read more

Creating mixture of shortcodes to use in the visual/text editor

I suggest to just append the other things to the content without editing the templates add_filter(‘the_content’,’hang_my_specific_things_on_the_content’); function hang_my_specific_things_on_the_content($content) { // shortcode0 is appended before content $content = do_shortcode(‘[shortcode0]’).$content; // these are appended after the content $content .= do_shortcode(‘[shortcode1]’); $content .= ‘<img src=”https://wordpress.stackexchange.com/questions/312880/someimage.png” />’; $content .= do_shortcode(‘[shortcode2]’); return $content; }

Invalid argument supplied for foreach()

You will get this error if foreach() is not an array. So your first step should be to debug this by inspecting the contents of $results to confirm that the results are what you expect. If it’s not then it might give you clues to why. This is debugging 101. If you do that you’ll … Read more

Shotcode error on functions

do_action is a WordPress function for running action hooks. I assume that is what you are trying to do. Given that, The first parameter, the only one in your case, needs to be an action hook name. If you pass it a valid hook name and have a function attached to that hook, this code … Read more

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