Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Issue with Ajax and WordPress Shortcode

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #242829
    chrchcol
    Participant

    I 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;
    }
    
    #242830
    rkieru
    Participant

    When 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);
    
    #242831
    chrchcol
    Participant

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

    #242845
    rkieru
    Participant

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.