I try to add addtoany shortcode in my custom loop page but the shared link stays always the same for each posts in the loop. <?php global $post; echo do_shortcode('[addtoany url="' . the_permalink() . '" title="' . the_title() . '"]') ?> I also tried with get_permalink(), get_permalink($post->ID), get_the_permalink()... but nothing works. It should work like this, according the official documentation. I don't understand why :/ EDIT Here is the full function: <?php add_filter( 'generate_do_template_part', function( $do ) { if ( …
I want to add video from youtube/vimeo to my post.Whenever i add a video to my post ,there will display a link like https://www.youtube.com/watch?v=dsUXAEzaC3Q in my admin(Add new post ),and in the front end it will display the video.But the problem is, i want to show the video like a shortcode example [video url=”https://www.youtube.com/watch?v=dsUXAEzaC3Q”][/video]in the place of original video.That is show the shortcode like above instead of the video in front end.How can it possible.Please help me.
For some reasons every shortcode, that I try to add to functions.php, displays only default attribute value and ignores what I specify in a post. E.g.: function my_shortcode( $atts ) { extract( shortcode_atts( array( 'id' => '18', ), $atts ) ); return $id; } add_shortcode( 'sc', 'my_shortcode' ); So I use shortcode [sc id="81"] and expect echoing 81 but I get 18. BTW I use child theme, and latest version of wordpress. I'm really stuck. Thanks for any help.
I am using AJAX to load next set of posts on homepage. The posts load fine but the shortcodes are not rendered. I am trying to use the do_shortcode function on the content the ajax call fetches (although experts have suggested not to use do_shortcode) but apparently it is failing. Here's my function that processes the request: function theme_load_more_posts() { check_ajax_referer( 'theme-load-more-posts-nonce', 'nonce' ); $args = isset( $_POST['query'] ) ? array_map( 'esc_attr', $_POST['query'] ) : array(); $args['post_type'] = isset( $args['post_type'] …
I have created a front-end editor using wp_editor that functions as it should. Upon testing I have noticed that it is stripping out any shortcodes that have been inserted in the content. I have looked into this issue and found that it's the 'ob_' (output buffering) that is removing them. If I remove this output buffering then the shortcodes display fine, but it breaks the functionality I have created for the editor. How would I keep the code I am …
I'm looking for a simple shortcode to pull in featured images without the blogpost title. Currently I am using: [display-posts category="OSH" image_size="standard"] which works, but with the titles. What do I change?
I am trying to automate a whole bulk of my pages and one of the shortcodes I have created is to output the NextGen Gallery Tags by using the page custom fields that each page has a unique id. This id is actually tagged into certain galleries which I want to output on the page. For those unfamiliar with NextGen Gallery tags shortcode. Please visit this link. Each page has a custom field "gallery_id" which I input a unique tagged …
TLDR; How can I run a shortcode with multiple shortcodes inside of it? I'm trying to run a shortcode with multiple shortcodes inside of it. I can successfully run a shortcode with one shortcode inside of it with the following code in the theme: add_shortcode('outside_shortcode', function($attr, $content = null) { return ' <section class="example_section"> <div class="container"> <div class="row"> ' . do_shortcode($content) . ' </div> </div> </section> '; }); add_shortcode('inside_shortcode', function($atts, $content = null) { $atts = shortcode_atts( array( 'link' => …
I want to add a timestamp to use as unique id for conversion tracking. I have a [[timestamp]] shortcode on my site. In text it works fine, but the shortcode does not work when placed inside the src attribute of an image tag, e.g.: <img src="http://example.com/transaction_id=[[timestamp]]"> Does anyone know a solution to this issue? The shortcode I use: // Do TimeStamper Shortcode ( timestamper() ) function timestamper( $atts ){ if (!is_admin()) { add_filter('widget_text', 'do_shortcode', 11); } $time = current_time( 'timestamp' …
I was wondering if I can show my featured image Dimensions (W x H in px) and the filesize in mb. In my Wordpress post with a shortcode. thank you in advance :)
I've created these two functions to toggle between the first paragraph of the content and then everything but the first paragraph so when the user selects 'More' it slides out the article smoothly without replacing the first paragraph that's already displayed as the excerpt. However if there's a shortcode in that text it shows up as the shortcode syntax rather than displaying properly. I understand why it's not displaying but I'd like to replace any shortcodes in the text so …
I basically have a contact form which generates a PDF output using a third-party plugin. The plugin allows for the use of shortcodes to add content to the final PDF. I want to be able to display the avatar image of the currently logged in user so the PDF is customized for them and not just a default look. The shortcode below works great and if I manually change the user_id it will changes the image perfectly to whom ever …
[box id='1' text="some texte"] the shortcode, at one point is outputting text the html result is : </p> some text </p> There is an extra closing paragraph in the start and and opening at the end... WHY ? where those come from ?.... any idea ?.. it screw my w3 validation ! ** note i have found that... but look all "patched" to me...any clean solution... wp is dirty ? reference
I am not sure if there is a simple solution to my problem. The requirement looks simple but unable to find answer even after breaking my head for 6 hours. I have to pass variable from a php function to a shortcode and this shortcode has to pass on the this variable to another shortcode. Shortcode-1 will open a popup and the content of the popup is created by shortcode-2, content has to be changed based on the variable. How …
Good afternoon. There is a shortcode [alltags] that displays ALL site tags on a separate page of the site in alphabetical order with a letter. function wph_alltags_shortcode( $atts, $content ) { $posttags = get_tags(); $output = ''; if ( $posttags ) { $output = '<dl class="alltags">'; foreach ( $posttags as $tag ) { $l = mb_strtoupper( mb_substr( $tag->name, 0, 1, 'UTF-8'), 'UTF-8' ); if ( $L != $l ) { if ( $L ) $output .= '</dd>'; $L = $l; …
I'm trying to use the WordPress do_shortcode function for the WooCommerce One Page Checkout Plugin which uses shortcode like this: [woocommerce_one_page_checkout template="product-table" product_ids="product, ids, here"]. I can ONLY use this shortcode IF it's in the content editor and it won't allow me to add this to a page template using the do_shortcode function. Their documentation here says: If you wish to display the One Page Checkout Shortcode using WordPress’ do_shortcode() function instead of including the shortcode in a post or …
I am building a website for a client, and I needed to build a game release calendar using Custom Post Type and Advanced Custom Fields. Everything is built out, but the last step. I need to be able to query the CPT automatically whenever a new game is added, and pull it into the WP Bakery Visual Composer front end via shortcode. Below is the code added to the functions.php file, but I'm getting syntax errors because of "<". Can …
I have a custom page template and I want it to display on specific pages. The only way I know to do this is to create a shortcode for this custom page template, so that I can use the custom page template by using shortcode. But I don't know how doing this. I saw some article about this, but I forgot the website link. How to create a shortcode for custom page template?
I'm trying to filter out the excerpt by character length for a plugin called "List Category Posts". I've been trying to get the excerpts working for the past week, but nothing is doing the trick. The plugin actually comes with a feature that allows you to post the excerpt or not, then filter it by character length.. by adding "excerpt_size=" in the shortcode. But unfortunately, it doesn't work at this time, and I've tested it with multiple different themes. Anyways, …