Shortcode in custom loop not automatically updating
-
Hi,
so I have created „dynamic pages“ where a page shows the content of one of it’s children-pages based on a session-variable.
In this case there is for example a main-page „locations“ that shows stores based on the states that are selected within the session-variable.
I built it this way so the permalinks will stay for example „/locations“ all the time and not „/locations/location_a-f“ or so on.When I now put a shortcode (which also shows values based on the session) in the content of a dynamic child-page it seems like I also need to save the main page where the content is loaded to update the shortcode values on session change.
I created a page template for the main pages with this loop:
$args = array( 'post_type' => 'page', 'meta_key' => 'page_is_dynamic', 'meta_value' => true ); $dynamic_pages = new WP_Query($args); //loops all pages that have been marked as dynamic while( $dynamic_pages->have_posts() ) { $dynamic_pages->the_post(); //if the page is a child of the current page AND the current state is also selected within this page, show content of the page if ( $post->post_parent == $page_id && in_array($_SESSION['bld'], get_field('bundesland_dynamic_page')) ) { the_content(); } } wp_reset_postdata();When the session changes, shortcodes that are also relying on that session-change are not updating their value until I save the mainpage by hand. For example the shortocde [state_name] is still showing the initial state I last saved the mainpage with in the session.
I also tried to
wp_update_post()
the mainpage on session-change but this didn’t do any change.Can anyone explain to me why the shortcodes are not updating themselves and if there is a way to solve this problem?
Thank you very much in advance!
The topic ‘Shortcode in custom loop not automatically updating’ is closed to new replies.