WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] easy question i hope on document relative linking (9 posts)

  1. bwhit
    Member
    Posted 4 years ago #

    Day one for me and wordpress so sorry if this question is silly. I'm trying to place some flash in my template using document relative linking versus absolute linking. I'm using the swfobject code to place it and am finding that on my main page it works great like it's supposed to. However, once you go a level or two down into the article and comment areas, the swf disappears.

    Is there some work around I missed? Thanks in advance.

  2. Wex
    Member
    Posted 4 years ago #

    Make sure that the code that you're placing isn't in a file that isn't globally shown, such as index.php. If you want it to show on all pages, you'll need to put it in your header.php, footer.php, or sidebar.php (if your site has one) files.

  3. bwhit
    Member
    Posted 4 years ago #

    It's actually in the "header.php" file. "../swf/thefile.swf" takes me from "header.php" to where the file is located. Shows up perfectly fine on the main page but once you click through to an article it loses the embedded file. It displays the alternative content I specified which is just some random text at the moment. That is what lead me to be believe there's some issue with the file paths.

  4. Wex
    Member
    Posted 4 years ago #

    Oh, if you're using "../", it is an issue with the paths. It's much better to use <?php get_stylesheet_directory() ?> for an absolute path. See if that solves your problem.

  5. bwhit
    Member
    Posted 4 years ago #

    right. thanks, i'll have to look up how to use that : ) wasn't joking when i said this was my first day.

  6. bwhit
    Member
    Posted 4 years ago #

    Yeah so, sorry, but I really don't understand what that function is doing. Looked at the info here on wordpress along with looking at the "theme.php" file the function is in. I realize it's just my lack of knowledge currently but it seems silly to me that there wouldn't be an allowance for some standard directory linking. I just need to know how to point to a few files on my server w/out the need for a direct "www...."

  7. I just need to know how to point to a few files on my server w/out the need for a direct "www...."

    The problem here is that I believe WordPress translates the relative link, based on what page you're on.

    Example: From http://domain.com if you called ../swf/thefile.swf that file clearly doesn't exist. You can't go up from root :) And from http://domain.com/foo/bar/index.php it would be looking in http://domain.com/foo/swf/thefile.swf

    See how that causes problems?

    So as Wex said, it's better to use <?php get_stylesheet_directory() ?>

    You do this: <?php get_stylesheet_directory() ?>/swf/thefile.swf and that translates to http://domain.com/wordpress/wp-content/themes/yourtheme/swf/thefile.swf and every thing should work :)

  8. bwhit
    Member
    Posted 4 years ago #

    yeah i understand all that was going on. i think i was just screwing myself up with not knowing where all this stuff lived. anyway, that really helped. it seems that "<?php bloginfo('stylesheet_directory'); ?>" did the trick though, but you got me off in the right direction! much appreciated.

  9. bwhit
    Member
    Posted 4 years ago #

    Thanks for the help Ipstenu + Wex. Site's up now, still a bit in progress, but moving forward nonetheless.

    http://brettastico.com/relaunch/randomthings/

Topic Closed

This topic has been closed to new replies.

About this Topic