Home › Forums › JavaScript › Issue with Ajax and WordPress Shortcode
- This topic is empty.
-
AuthorPosts
-
June 13, 2016 at 1:56 pm #242829
chrchcol
ParticipantI have an ajax menu that grabs content and displays it in a content window. That is working perfectly except it is stripping the [productpage] shortcode for wp-ecommerce from the order page if you click the link from the menu to get to that page
Here is the function for the menu
function get_page_content(){ global $wpdb; $page_url = isset($_POST['page_url']) ? $_POST['page_url'] : ''; if ( $page_url ) { $postid = url_to_postid( $page_url ); /* $post = get_post($postid); $content = $post->post_content; $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); echo $content; */ $the_query = new WP_Query( 'page_id='.$postid ); while ($the_query -> have_posts()) : $the_query -> the_post(); simple_boostrap_display_post(false); endwhile; } else{ echo 'Invalid request'; } die; }
June 13, 2016 at 2:37 pm #242830rkieru
ParticipantWhen you say it is stripping the
[productpage]
short code, what exactly is it doing? Omitting that entirely, showing that exact text, or something else?If I had to hazard a guess (and without more details it really is just a guess) I would assume the issue to be with:
$content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content);
June 13, 2016 at 2:39 pm #242831chrchcol
ParticipantIt shows [productpage] when clicking the order button from the menu. However if I load the page directly without going through the menu, it shows the cart fine. I also wanted to mention that add filter bit is commented out.
June 14, 2016 at 5:56 am #242845rkieru
ParticipantI’m not familiar with WP e-Commerce, but it sounds like whatever method you’re using to call this page up via Ajax is bypassing whatever hooks are used in the plugin for parsing their plugin-specific short codes.
It’s rather a nightmare to provide any meaningful suggestion without having more information.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.