Quantcast
Channel: Topic Tag: xml | WordPress.org
Viewing all articles
Browse latest Browse all 3201

FebzPD on "load custom xml file to be used in wordpress page"

$
0
0

Hi,
I'm trying to load an xml file in order to read it's content and print it based on the user logged in. To do so I created a shortcode in functions.php in my child theme folder. Here's the code I wrote:

function dati_tbcrew($atts){
	global $user_login;
	get_currentuserinfo();
	$xml=simplexml_load_file("porva.xml") or die("Error: Cannot create object");
	switch($xml->name['nome']){
		case $user_login: $out=$xml->name->content;break;
		default:break;
	}
	return $out;
}
add_shortcode('dati_tbcrew', 'dati_tbcrew');

Unfortunately when I call the shortcode in a WP page it prints out "Error: Cannot create object". The XML file is in the child theme folder with functions.php. I even tried to put the server folder route in with the file's name in simplexml_load_file but it still isn't working. How can I get it working? Is it even the right procedure? Thanks in advance.


Viewing all articles
Browse latest Browse all 3201

Trending Articles