• Resolved gyunduz

    (@gyunduz)


    I created slider for news website, slider from posts. But when I add a new post with corresponding tag it doesn’t show up in the slider automatically. It only shows up after I have to update the slider every time. How to resolve it?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author bqworks

    (@bqworks)

    Hi,

    That’s because of the slider’s caching. To clear it automatically when you add a new post, please add this PHP code in your theme’s functions.php:

    add_action(‘save_post’, ‘clear_slider_cache’);

    function clear_slider_cache() {
    global $wpdb;
    $prefix = $wpdb->prefix;

    $wpdb->query( “DELETE FROM ” . $prefix . “options WHERE option_name LIKE ‘%sliderpro_cache%'” );
    }

    Best,
    David

    Thread Starter gyunduz

    (@gyunduz)

    Thanks for quick support,

    but when I try to add this code I receive error:
    (syntax error, unexpected ‘WHERE’ (T_STRING), expecting ‘)’)

    in this line:

    $wpdb->query( “DELETE FROM ” . $prefix . “options WHERE option_name LIKE ‘%sliderpro_cache%’” );

    Plugin Author bqworks

    (@bqworks)

    Please try to retype the single and double quotations from that line of code.

    Best,
    David

    Thread Starter gyunduz

    (@gyunduz)

    I tried this code

    add_action('save_post', 'clear_slider_cache');
    
    function clear_slider_cache() {
    global $wpdb;
    $prefix = $wpdb->prefix;
    
    $wpdb->query( "DELETE FROM" . $prefix . "options WHERE option_name LIKE '%sliderpro_cache'" );
    }

    functions.php saved successful.
    But nothing happens, cache is not cleared and now I receive this in error.log:

    [11-Feb-2022 13:30:49 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE option_name LIKE '%sliderpro_cache'' at line 1 for query DELETE FROMwQQp_options WHERE option_name LIKE '%sliderpro_cache' made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, WP_REST_Server->respond_to_request, WP_REST_Posts_Controller->update_item, wp_update_post, wp_insert_post, do_action('post_updated'), WP_Hook->do_action, WP_Hook->apply_filters, wp_save_post_revision, _wp_put_post_revision, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, clear_slider_cache
    [11-Feb-2022 13:30:49 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WHERE option_name LIKE '%sliderpro_cache'' at line 1 for query DELETE FROMwQQp_options WHERE option_name LIKE '%sliderpro_cache' made by require('wp-blog-header.php'), wp, WP->main, WP->parse_request, do_action_ref_array('parse_request'), WP_Hook->do_action, WP_Hook->apply_filters, rest_api_loaded, WP_REST_Server->serve_request, WP_REST_Server->dispatch, WP_REST_Server->respond_to_request, WP_REST_Posts_Controller->update_item, wp_update_post, wp_insert_post, do_action('save_post'), WP_Hook->do_action, WP_Hook->apply_filters, clear_slider_cache
    Thread Starter gyunduz

    (@gyunduz)

    I solved the problem, added code [sliderpro id=”3″ allow_cache=”false”] without any functions.php. Thanks

    Plugin Author bqworks

    (@bqworks)

    That code disables the caching, but I would recommend using it, especially for dynamic sliders. I will try to check why that error appears.

    Best,
    David

    • This reply was modified 2 years, 9 months ago by bqworks.
    Plugin Author bqworks

    (@bqworks)

    Does this work for you?

    add_action('save_post', 'clear_slider_cache');
    
    function clear_slider_cache() {
    global $wpdb;
    $prefix = $wpdb->prefix;
    
    $wpdb->query( "DELETE FROM" . $prefix . "options WHERE option_name = '_transient_sliderpro_cache_3'" );
    $wpdb->query( "DELETE FROM" . $prefix . "options WHERE option_name = '_transient_timeout_sliderpro_cache_3'" );
    }
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘New created posts not shown on Slider Pro’ is closed to new replies.