Support » Plugins » Abspath?

  • Resolved teejayuu


    Having successfully written my first plug-in (I like it and it works), I thought I would move on to something a little more ambitious, that will hopefully increase my knowledge of WP and how it works. I am writing a simple gallery plug-in. I know there are a lot about, but none seem to do what I really want and using someone else’s (no matter how good) defeats the object of me learning how to write plug-ins.

    Anyway I have created 2 folders, one that contains medium images and the other contains the thumbnail images. Naturally I want to be able to display the thumbnail as a link to the medium image and am using the code
    define('TJIMAGE_PATH', ABSPATH . 'images/tj-gallery');
    to define the path to the gallery and

    $query = "SELECT photo_name FROM wp_tjgallery_photo WHERE cat_id = $c_id";
    $result = @mysql_query($query);
    while ($row = mysql_fetch_array($result, MYSQL_NUM)){
    echo'<tr><td><a href="' . TJIMAGE_PATH . '/medium/' . $row[0] . '">. TJIMAGE_PATH . '/thumb/thumb_' . $row[0] . '"</td></tr>';

    to create the link. However this shows the full path to my gallery and clicking the link gives a 404 error.
    I think the problem lies in my use of ABSPATH, but I cannot seem to find any documentation for this and have just picked up what I can from deconstructing other plug-ins. Can anyone see where I’m going wrong? An example can be found here

Viewing 1 replies (of 1 total)
  • Definitely not correct.

    ABSPATH is the server’s path to the wordpress main root directory. You use it in things like includes and requires and such. Anytime you need to reference a local file.

    If you’re building an actual link, you want to use the bloginfo() or get_bloginfo() functions. bloginfo() will display a parameter, get_bloginfo() will return it to you as a string.

    So, try this:
    define('TJIMAGE_PATH', get_bloginfo('url'). 'images/tj-gallery');

    More info here:

Viewing 1 replies (of 1 total)
  • The topic ‘Abspath?’ is closed to new replies.