shortcode with $atts with strange results

The functions you have above don’t use the id att at all. This might be what you want, but I’m not 100% sure what you’re going for. function show_homepage_banner_function($atts) { $atts = shortcode_atts( array(‘id’ => NULL), $atts ); $content=””; global $wpdb; $upload_url=””; $upload_dir = wp_upload_dir(); $target_dir = $upload_dir[‘basedir’]; $upload_url = $upload_dir[‘baseurl’].’/banners/’; $query = “SELECT * … Read more

Get taxonomy image for Toolset custom taxonomy through Toolset Views Shortcode

The following code is partialy taken from the plugin Taxonomy Images and it’s working: function get_taxonomy_image( $atts ) { $atts = shortcode_atts( array( ‘image_size’ => ‘thumbnail’, ‘id’ => ”, ), $atts ); if( ! empty( $atts[‘id’] ) ) { $term = get_term( $atts[‘id’] ); $related_id = 0; if ( isset( $term->term_taxonomy_id ) ) { $related_id … Read more

How to call shortcode on button click

You can’t add a shortcode to PHP directly. However, each shortcode executes a function, so you can just add that function to your link code. If your shortcode is something like this: function my_custom_shortcode( $atts, $content= NULL) { shortcode function } add_shortcode ( ‘my_custom_shortcode’ , ‘my_custom_shortcode’ ); use this in your link: <a href=”https://wordpress.stackexchange.com/questions/253796/<?php my_custom_shortcode(); … Read more

add post type pram to wp shortcode

Do you want to be able to switch between post types? If not, seems to me you could just duplicate the same functionality as you’re using with the per_page parameter, meaning: In your shortcode function just add a data attr to the #container-async div for the post_type(s). <div id=”container-async” data-paged=”<?php echo $a[‘per_page’]; ?>” data-posttype=”<?php echo … Read more

Sorting Woocommerce products by category and attributes

Hi @ColinTravis you can use following function in functions.php : /** * Defines the criteria for sorting with options defined in the method below */ add_filter(‘woocommerce_get_catalog_ordering_args’, ‘custom_woocommerce_get_catalog_ordering_args’); function custom_woocommerce_get_catalog_ordering_args( $args ) { global $wp_query; // Changed the $_SESSION to $_GET if (isset($_GET[‘orderby’])) { // switch ($_GET[‘orderby’]) : // case ‘pa_pub-year’ : $args[‘order’] = ‘ASC’; //$args[‘meta_key’] … Read more

How to scroll to a shortcode-generated anchor

It’s not really a WordPress related question, but since it was simple I posted an answer for you. You can scroll to your element by using jQuery. Check if the query var is set, if so, scroll to the element after the page has been loaded: (function($){ // Function to get the current query var … Read more

Shortcode Site include in a other

It is very hard to understand what you are trying to ask? Do you want to know how to use a plugin’s shortcode? if so, then you can copy the shortcode in the content section of the new post or page. For Example, if the shortcode for the plugin is [plugin-shortcode]. Then just publish or … Read more

Display posts from another page on home page in wp-editor

I created shortcode in functions.php: add_shortcode(‘projects’, ‘projects_shortcode’); function projects_shortcode($atts){ extract(shortcode_atts(array( ‘post_type’ => ‘project’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3, //’caller_get_posts’ => 1 ), $atts)); $args = array( ‘post_type’ => $post_type, ‘post_status’ => $post_status, ‘posts_per_page’ => $posts_per_page ); global $post; $posts = new WP_Query($args); $out=””; if ($posts->have_posts()) while ($posts->have_posts()): $posts->the_post(); $overview_image = get_field(‘small_overview_image’); $out .= ‘<div … Read more

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