woocommerce Product shortcode create [closed]

Hello Here is the Shortcode you can use this it will give you title link and image of product. Put this code in functions.php file of your theme. add_shortcode(‘product_data’,’custom_product_function’); function custom_product_function($atts) { $post_id = $atts[‘id’]; $title = get_the_title($post_id); $link = get_the_permalink($post_id); $image = get_the_post_thumbnail($post_id); $data=”<div><a href=””.$link.'”><p>’.$title.'</p></a>’. $image.'</div>’; return $data; } And then add the shortcode … Read more

Shortcode Output Always Before Content [duplicate]

Return the HTML instead of the echo function dataservices_category($atts) { // Attributes extract(shortcode_atts(array( ‘id’ => ” ), $atts)); $html = “”; // Code if (isset($id)) { $categories = get_categories(‘child_of=” . $id); foreach ($categories as $category) { if ($category->parent != $id) { $html .=”<div style=”margin-left:50px;”>’; $html .='<h4>’ . $category->name . ‘</h4>’; } else { $html .='<h3>’ … Read more

WordPress Shortcode loads at the top

First, declare your variable: $return = ”; Then, throughout the code, concatenate items: $return .= ‘<div class=”sp shadow”><img src=”https://wordpress.stackexchange.com/questions/81864/…”></div>’; $return .= ‘<h3>Videos</h3>’; And finally, return the result: return $return;

How wp maps urls into files

Go to “Pages” and find the page with the ID. Open it in editor. On the right hand side, look for “page attributes”. You can add php files here. All you have to do is, create a PHP page under your theme, and add this to your beginning of the file: <?php /* Template Name: … Read more

Shortcode not passing variable to included file

Ok, so somehow I got it working by changing it to this: It looks like it didn’t like ‘the_clientId’. Maybe it just doesn’t like capital letters???? [insert-form form_location=”form.php” identification_number=”12345″] function insert_the_form($atts){ $form_base = plugin_dir_path(__DIR__); // Shortcode attributes & options $atts = shortcode_atts( array( ‘form_location’ => ‘NULL’, ‘identification_number’ => ‘NULL’ //Variable for client ID ), $atts, … Read more

Trying to Understand Shortcodes.

I would recommend using a shortcode, because its easy to use and at the same time efficient. Below I have attached the code, how you can put your code into a shortcode. the add_shortcode function is what you use when you want to create a shortcode. To use it, you simply need to write [render_slider_shortcode] … Read more