Tag Info

New answers tagged

1

The simplest and quickest solution would be to use the add_rewrite_endpoint function. <?php add_rewrite_endpoint( $name, $places ); ?> So in your case it would be something like this: add_rewrite_endpoint( 'user', EP_PERMALINK | EP_PAGES ); An user URL would look like this: http://www.example.com/my-page/user/john To access the variable: ...


3

As I already stated in comments, your code is a complete mess and very hard to read and to debug. This is most probably why you are having a hard time to sort your issues. Apart from a few syntax errors, you had a couple of bugs in your code like undefined variables (like your counters, you should define a counter before using it), trying to output an ...


2

As I have stated, you can do all of the above in your question with only one shortcode. The idea here would be to Use usort() to sort posts according to term name Pass a string of term names in the order you need to display them to the shortcode FEW IMPORTANT NOTES Never ever use extract(). It is unreliable and extremely hard to debug when it fails. ...


1

Before we start may I just quickly mention that for the future it is easier to reference the post by its ID instead of the URL as this is going to stay the same when slugs change. Anyway as you already have this shortcode now we need another solution. Your problem is that you need to find a post from its URL when the permalink changed. Fortunately the old ...


1

I don't know why the code is not working. But this is how i did this may be helpful for some noob like me <?php $name = get_the_content(); preg_match('/\[gallery ids="([^]]*)\"]/', $name, $match); $w3_ids = explode( ",", $match[1] ); $gallery_count=1; foreach( $w3_ids AS $w3_id ): ...


-1

<?php $id=the_ID(); $gallery_count = $wpdb->get_var("SELECT COUNT(ID) FROM {$wpdb->prefix}posts WHERE post_type = 'attachment' && ID=$id"); echo $gallery_count; ?> I think...!!! Try this for Particular gallery.


0

The hook to use here is admin_notices. However in register_activation_hook and register_deactivation_hook it shouldn't be used because these function run when plugin activates and deactivates instance. A workaround it we use add_option when plugin activates and delete_option when plugin deactivates. Here is the code. Hopefully you will understand it ...


0

ANSWER <?php // my shortcode look like this. [tabgroup] [tab title="Your title #1" class="active" ] Your Description here #1 [/tab] [tab title="Your title #2" ] Your Description here #2 [/tab] [tab title="Your title #3" ] Your Description here #3 [/tab] [/tabgroup] add_shortcode( 'tab', ...


0

Following on from @Otto, you need to capture the output from the action, and then pass it through the shortcode: ob_start(); do_action( 'tribe_events_single_event_after_the_meta' ); $calendar = ob_get_clean(); $password = get_post_custom_values( 'password' ); if( ! empty( $password ) ) { echo do_shortcode( "[content_protector ...


1

you can override the shortcode like this : add_action("init", function () { remove_shortcode("timelinr"); add_shortcode("timelinr", function ($atts, $content) { // call the shortcode of jqueryTimelinrLoad $result = $GLOBALS["jqueryTimelinrLoad"]->shortcode($atts, $content); // dequeue style ...


2

do_action does not return text, it just does the action. So, calling do_action( 'tribe_events_single_event_after_the_meta' ) in your do_shortcode call there will cause the iframe to be output before the shortcode.


1

I haven't tested this but based on memory, you are misunderstanding how shortcodes work. The "content" isn't passed through the callback the way you seem to expect it to be. The content is extracted from the post body via a preg_* function. That, if my memory serves, is going to give you "content" as a string no matter what you try to pass into it. As ...


0

You can use like this, shortcode inside the Class class stockData{ function __construct() { add_shortcode( 'your_shortcode_name', array( $this, 'showData' ) ); //add_action('login_enqueue_scripts', array( $this,'my_admin_head')); } function showData(){ return '<h1>My shortcode content</h1>' ; } } ...


-1

Please try this one function show_aip_popup($args){ wp_enqueue_script( 'parent-stylesheet', 'javascript file', false ); //your code for show shortcode data }


1

Thank you for your help I have do some googling and finally i got the ans i have added just 1 line of code into the shortcode function and i got the ans. I have added bellow line into the shortcode function . wp_enqueue_script( 'parent-stylesheet', '[js URL]' . $postId, false );


3

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 ...


2

The main problem here is WordPress COM and ORG are NOT equal. Questions about support for the former are actually off-topic on WordPress Development. One consequence of the non-equality of com and org is that the latter has no shortcode [instagram], so naturally it won't work - the built-in shortcodes can be seen at this list. On the other hand, you are ...


1

Normally Wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags. Add the following in your template file, it can be single.php ...


0

I found an other way that works well for me: When initializing the plugin, do not enqueue your scripts and styles, but register them with wp_register_style and wp_register_script. Next you can load the script/style on demand. For example when you render a shortcode with wp_enqueue_style("your_style") and wp_enqueue_script("your_script"). This way the ...


0

Nevermind, I solved it on my own. While reading on the WordPress Codex for $wpdb, I saw that if I use OBJECT_K it will remove the duplicates and that solved my problem. If it helps anyone, here is my working code: function latest_posts_after_last_login( $atts ) { global $wpdb, $current_user; $atts = shortcode_atts( array( 'post_type' => ...


5

Shortcode callback should return it's output and not echo it. Something like this should work just fine: function get_loggedin_avatar (){ global $current_user; $result = ''; if ( is_user_logged_in() ) { get_currentuserinfo(); $result = '<a href="/myaccount">'. get_avatar( $current_user->ID, 96, left ). ...


1

Use this instead: Concatenate the html then return it. function check_my_login( $atts) { $html = '<form action="" name="" method="post" enctype="multipart/form-data">'; $html .= '<div class="form-group">'; $html .= '<label for="description">Project Description</label>'; $html .= '<textarea name="p_description" ...


0

I was able to solve this by using str_replace. function mp_filter_download( $result ) { $search = '<div style="clear:both;"></div>'; $replacewith = ' '; return str_replace( $search, $replacewith, $result ); } add_filter( 'downloads_shortcode', 'mp_filter_download', 10, 2 );


0

The answer below doesn't directly answer your question but provides a possible alternative solution. Drop has_shortcode( $post->post_content, 'my-shortcode' ) statement. There is no need to check this if you are validating nonce. So the validation should look something like this. function project_registration_login_redirection(){ if ( !isset( ...



Top 50 recent answers are included