user2930069
user2930069

Reputation: 49

XML and WordPress assistance

My developer set up a datastream connection to an outside source that is pulling product into my WordPress website. I need to use code similar to the code below to show the categories. There is also code for the search box.

How do I insert this code into a WordPress page so that it shows the categories?

<?xml version="1.0" encoding="UTF-8"?>
<XMLDataStreamRequest>
<Ver>3.2</Ver>
<Auth>
<AcctID>XXXXXX</AcctID>
<LoginID>XXXXXX</LoginID>
<Password>XXXXXXXXXXXX</Password>
</Auth>
<CategoryList>
<GetList>1</GetList>
<Sort>NAME</Sort>
</CategoryList>
</XMLDataStreamRequest>

Upvotes: 0

Views: 30

Answers (1)

lvollmer
lvollmer

Reputation: 1608

Okay, as far as I understand you want you to create one where the list is displayed.

1

Create a site in the backend called "categorylist"

2

you create a file in your theme called page-categorylist.php

Please try now that when you open the categorylist page that if it's just white. if it's not you made a mistake.

3

put this in the file:

<?php
header('Content-Type: text/xml');

function getCats() {
$categories = get_categories();
$src .= "<XMLDataStreamRequest><Ver>3.2</Ver><Auth><AcctID>XXXXXX</AcctID><LoginID>XXXXXX</LoginID><Password>XXXXXXXXXXXX</Password></Auth><CategoryList>"
foreach($categories as $category) {
              src .= "<GetList>" . $category->term_id . "</GetList><Sort>" . $category->name ."</Sort>";
}
$src .= "</CategoryList></XMLDataStreamRequest>"

    return $src;

}

echo getCats();

Upvotes: 0

Related Questions