I obviously need more knowledge re this one. From my plugin. I have a custom main page which displays my custom db data table of a list of stores. Each store has a "link" ie using a href eg.

<a href='wp-content\plugins\SBaronAdmin\Menus.php?xp=<?=$row->BrExpress;?> '>
<img src='images/full_menu_icon.gif' 
alt='See this store menu' class='menuimg' /></a>

but, the called page has an issue using $wpdb. I assume it is because it is not recognised as a WordPress page. though the called page resides in the plugin folder.

I have tried this as well as function calls and also Shortcodes (beneath,..which don't work..I've done something wrong obviously) eg.

 <a [caption] <?=$row->Express;?> [/caption]
 <img src='images/full_menu_icon.gif' 
 alt='See this store menu' class='menuimg' /></a>


  function Platters_shortcode( $atts, $content = null ) 
     return '<a href="Platters.php?xp="' .  $content . '>';
  add_shortcode( 'caption', 'Platters_shortcode' );

but to no avail.

Can anyone puh-lease point me in the right direction TIA

  • 1
    How are you loading your page? It sounds like the page is not being loading into WordPress. Just because it is in the plugins folder does not automatically mean it will have access to WordPress functions or the database. – Pippin Feb 14 '12 at 14:43
  • From the href link. "Menus.php" above. – Neal Feb 15 '12 at 5:53
  • I tried creating my outout via function and including that in my main plugin page. and used admin init. That gave output into the main page (and also straight into the admin dashboard),...so maybe the correct way to do it is functions and shortcodes of those,..but thats not working out too well. the idea being the custom pages canthen just use the shortcode, which invokes the function which outputs html and db data. ???? – Neal Feb 15 '12 at 5:57
  • Instead of showing snippets, can you show your complete code? – Pippin Feb 20 '12 at 14:48

I would do something like this:

<a href="?xp=<?php echo $row->BrExpress; ?>">
<img src='images/full_menu_icon.gif' 
alt='See this store menu' class='menuimg' /></a>

And then to load the page when the link is clicked:

function load_the_menu_page() {
    if(isset($_GET['xp'])) {
        global $wpdb;
        // retrieve database info here

        return $info;
add_action('init', 'load_the_menu_page');

Note, this is just a sample. If you do something like this you should greatly improve it. You will want to use a nonce and also name your functions appropriately.

It's still not very clear as to what exactly you're trying to do, so if this isn't close, please try explaining more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.