[resolved] Shortcode args not refreshing (7 posts)

  1. AndrewShea
    Posted 3 years ago #

    Ive wrote a plugin that takes an argument. When I change the argument in the shortcode it doesn't change the result and acts like the old arg is still being provided.

    I've done all the various cache refreshes (soft/hard/full) and it seems random when it actually changes (anything from immediately to a day later - my workflow is being seriously affected)

    Not sure what I can show in the way of code but heres the short code format
    [ajs_push_content content="intro-test1" link="none"]

    and the code is

    function push_post_as_content($atts)
    $fargs = shortcode_atts( array(
    		'section' => '-999',
    		'link' => '#',
    	), $atts );
    if($section != "-999"):
      $ajs_test = "#".$section."#<hr>";

    When no arg is given its sometimes showing the previous arg, then when one is given its showing the -999....

    Pulling my hair out - never had this problem before with shortcodes.

  2. ianhaycox
    Posted 3 years ago #

    I know you said you flushed the caches but was that the browser cache ?

    I've come across a similar situation before with one of the caching plugins, can't remember which one. Either disable any caching plugins if you have them, or add the page to the exception list in the cache plugin.


  3. AndrewShea
    Posted 3 years ago #

    Thanks for your reply. This is a clean install without any other plugins apart from the custom fields one. Is there anything within wordpress itself that acts like a cache?

  4. AndrewShea
    Posted 3 years ago #

    Its definitely not a client side problem as it happens on my phone too. Its either server/application or something Im doing wrong...

  5. ianhaycox
    Posted 3 years ago #

    Sorry out of ideas. I can only suggest initialising $section to a known value before calling shortcode_attr() Maybe there's a global $section somewhere, or it's a 'reserved' WP query var ?

    Good luck

  6. bcworkz
    Posted 3 years ago #

    FWIW, WP does cache some data, AFAIK it is very short term, as in for the duration of a single request. Though I have noticed many transients get saved as well but I can't imagine they have anything to do with shortcode attributes.

    It is possible your host is caching your pages though, you could inquire with them, or use WP installed on a local test server such as XAMPP to take the host factors out of the equation.

  7. AndrewShea
    Posted 3 years ago #

    D'oh - programmer error
    im passing the parameter 'content' but looking for 'section'...such a 'rookie' mistake... anyone would think that I hadnt been programming since 1981! Thanks for your replies

Topic Closed

This topic has been closed to new replies.

About this Topic