How do I apply style to each category of a list?

I’ve modified your code to reflect the wp_list_categories() function reference as suggested by @Usce. This snippet will create an unordered list, remove the “Categories” list title, and add the li class with individual category ID so you can target each link in the list. function catting ($atts, $content = null) { echo ‘<div id=”cats” class=”catting”>’ … Read more

My shortcode does not call the function

Please replace the old code with below code it will show you that it’s working add_shortcode( ‘bg_recent_post_grid’, ‘bg_recent_post_grid_shortcode’ ); function bg_recent_post_grid_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( ‘category_name’ => ‘uncategorized’, ‘number_posts’ => ‘1’, ), $atts ); return bg_make_post_grid ( $atts[‘number_posts’], $atts[‘category_name’] ); } function bg_make_post_grid ( $number_posts, $category_name ) { $args = … Read more

Inject HTML meta tag inside wordpress tag using add_shortcode

First thing, wp_head action hook does not accept any argument at all, so am not sure whether the $url variable will be passed. To run the short code properly, you have to call do_shortcode(): add_action( ‘wp_head’, ‘refresh_page’ ); function refresh_page() { echo do_shortcode( “[refresh url=”http://stackoverflow.com”]” ); } add_shortcode( ‘refresh’, ‘refresh_shortcode’ ); function refresh_shortcode( $atts ) … Read more

Creating a short code with php inside

I stripped out a lot of the code that wouldn’t be needed in a shortcode: function sx372821_request_quote_button( $atts = array() ) { global $product; $atts = shortcode_atts( array( ‘button_text’ => get_option( ‘wc_quote_button_text’ ), ), $atts, ‘request_quote_button’ ); $product_id = $product->get_id(); $wc_quote_button_text = esc_html( $atts[‘button_text’] ); if ( empty( $wc_quote_button_text ) ) { $wc_quote_button_text = esc_html__( … Read more

How to Create a shortcode to this php function

You can use the add_shortcode function to do that. You just need to pass your isa_before_add_to_cart_form function as a shortcode like this: add_shortcode( ‘isa_show_link’, ‘isa_before_add_to_cart_form ); Now you can use the shortcode [isa_show_link] to display it anywhere. It’s simple.

TinyMCE buttons that launch Ajax-generated forms

by using jQuery.ajax(): so, instead of that big form variable: $.ajax({ type: ‘GET’, url: ‘admin-ajax.php’, data: { action: ‘get_my_form’ }, success: function(response){ var table = $(response).find(‘table’); // you don’t seem to use this “table” var $(response).appendTo(‘body’).hide(); // … } }); Now, the php: add_action(‘wp_ajax_get_my_form’, ‘get_my_form’); function get_my_form(){ // build your form here and echo it … Read more

Placing tags on wordpress visual editor using shortcodes

Assuming you don’t have the shortcode written down… function search_shortcode() { $struct=”<div class=”searchbar” ><div class=”searchbar-inner” >search <input type=”text” id=”search” /><span class=”result-count” ></span></div></div>”; return $struct; } add_shortcode(‘search_box’, ‘search_shortcode’); Make sure your editor is in the ‘HTML’ mode, and paste the shortcode as ‘search_box’. Using a shortcode will allow you to reuse this form anywhere you want.

Why Won’t my jQuery Play Nice with WordPress?

WordPress automatically loads jQuery in “no conflict” mode so that it will be compatible with other libraries. This means the $ variable isn’t used for jQuery within WordPress. Rewrite your code to use the full jQuery keyword when you begin your closure like this: jQuery(document).ready(function($) { // … other code in here }); This is … Read more