New Landing How can we help? Themeforest Theme Support Neighborhood Just one problem with Functions.php

Viewing 10 posts - 1 through 10 (of 10 total)
  • #64781
    nicolasnom
    Member
    Post count: 29

    Hi there,

    I’ve just updated my neighborhoods theme, WordPress and Woocommerce. That’s works fine!
    I have just one problem with Functions.php. I have a custom function (founded in a forum) which create an shortcode for import an entire page with the ID. Unfortunately, now, the code works but stop the page charging. here’s the following code :
    And an exemple page :
    http://www.n o r d k r a f t.fr/s/bagues/bike-chain-bague-argent-oxyde/

    /**
    * Create a shortcode to insert content of a page of specified ID
    *
    * @param array attributes of shortcode
    * @return string $output Content of page specified, if no page id specified output = null
    */
    function pa_insertPage($atts, $content = null) {
    // Default output if no pageid given
    $output = NULL;

    // extract atts and assign to array
    extract(shortcode_atts(array(
    “page” => ” // default value could be placed here
    ), $atts));

    // if a page id is specified, then run query
    if (!empty($page)) {
    $pageContent = new WP_query();
    $pageContent->query(array(‘page_id’ => $page));
    while ($pageContent->have_posts()) : $pageContent->the_post();
    // assign the content to $output
    $output = apply_filters( ‘the_content’, get_the_content() );
    endwhile;
    }
    return $output;
    }
    add_shortcode(‘pa_insert’, ‘pa_insertPage’);

    Thank you

    #64874
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    HI,
    Please put this code again in your functions.php at child theme then you will not get this type of issue .

    Thanks

    #65053
    nicolasnom
    Member
    Post count: 29
    This reply has been marked as private.
    #65055
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I have resolved your issue so please check it now .
    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #65067
    nicolasnom
    Member
    Post count: 29

    I just tested and It don’t work with Safari and Chromium :s

    I removed the comment symbol /* */ for activated my shortcode, in functions.php in Child Theme.
    But same problem, the code works but the page doesn’t load all elements. All JS is blocked.

    #65162
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    HI,
    Please create same page at page editor instead of using shortcode and check. It should work .
    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #65449
    nicolasnom
    Member
    Post count: 29

    Thank you for your proposal, but I’va to add each page on 700 products ? I prefer use an short code. Plus, It’s a good way when I import many products, because the shortcode can be imported in same time.

    #65708
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    HI,
    Please provide me url of page as you used here http://www.n o r d k r a f t.fr/s/bagues/bike-chain-bague-argent-oxyde/ so i can know exact issue with this .

    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

    #66433
    nicolasnom
    Member
    Post count: 29

    Resolved with this new code function :

    /* Insert Page ID */
    
    add_shortcode('pa_insert', 'pa_insertpage');
    
    function pa_insertpage( $atts, $content = null ) 
    {
        // Default output if no pageid given
        $output = '';
    
        // Access $atts directly, no need of extracting
        if( !isset( $atts['page'] ) )
            return $output;
    
        // Grab the page directly, no need of WP_Query
        // get_post() could be used as well
        $get_page = get_page( $atts['page'] );
        if( !$get_page )
            return $output;
    
        // Do Shortcode in case the other page contains another shortcode
         $output = do_shortcode( $get_page->post_content );
         return $output;
    }
    #66439
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    I’m glad that issue resolved .
    Thanks ๐Ÿ™‚
    With Best Regards
    Swift Ideas

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register