Digital experiences for all disciplines
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Just one problem with Functions.php
New Landing › How can we help? › Themeforest Theme Support › Neighborhood › Just one problem with Functions.php
- This topic has 9 replies, 2 voices, and was last updated 10 years by Mohammad – SUPPORT.
-
Posted in: Neighborhood
-
April 7, 2014 at 4:01 am #64781
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
April 7, 2014 at 10:20 am #64874HI,
Please put this code again in your functions.php at child theme then you will not get this type of issue .Thanks
April 7, 2014 at 4:15 pm #65053This reply has been marked as private.April 7, 2014 at 4:25 pm #65055Hi,
I have resolved your issue so please check it now .
Thanks ๐
With Best Regards
Swift IdeasApril 7, 2014 at 4:59 pm #65067I 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.April 8, 2014 at 6:27 am #65162HI,
Please create same page at page editor instead of using shortcode and check. It should work .
Thanks ๐
With Best Regards
Swift IdeasApril 8, 2014 at 7:03 pm #65449Thank 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.
April 9, 2014 at 2:30 pm #65708HI,
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 IdeasApril 11, 2014 at 2:50 pm #66433Resolved 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; }
April 11, 2014 at 2:54 pm #66439Hi,
I’m glad that issue resolved .
Thanks ๐
With Best Regards
Swift Ideas -
Posted in: Neighborhood
You must be logged in and have valid license to reply to this topic.