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

Is there a way I can return terms by name using a shortcode?

This is the solution to get post terms by taxonomy by shortcode: /** * Custom shortcode to get terms */ function ALC_post_terms_by_taxonomy( $atts ) { global $post; $taxonomyTerms = wp_get_post_terms( $post->ID, $atts[‘taxonomy’], ‘orderby=name&hide_empty=0’ ); $term_array = array(); foreach ($taxonomyTerms as $taxonomyTerm) { $term_array[] = $taxonomyTerm->name; } return implode( ‘, ‘, $term_array ); } add_shortcode(‘get_terms_by_taxonomy’, ‘ALC_post_terms_by_taxonomy’); … Read more

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