[solution] Call to a member function get_permalink() on a non-object
-
Hello WordPress fans!
I ran across a solution to a problem, and will share it here. Feel free to reply with correction and improvements if the solution is less than optimal….I needed to fetch a gallery in an ajax-call. Basically I tried to do something like this:
$somevar = do_shortcode('[nggallery id=something]');
…. so I could pass the gallery html back to the script.
This produced a fatal php error, Call to a member function get_permalink() on a non-object .After googling and researching, I figured out how to avoid core file editing.
Just include a few lines of code above your do_shortcode(), a-like so:<?php #### PHP CODE START #### include($_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/nextgen-gallery/lib/rewrite.php'); global $nggRewrite; $nggRewrite = new nggRewrite(); //Now you can safely do the do_shortcode! $somevar = do_shortcode('[nggallery id=something]'); #### PHP CODE END #### ?>
https://www.ads-software.com/extend/plugins/nextgen-gallery/
- The topic ‘[solution] Call to a member function get_permalink() on a non-object’ is closed to new replies.