Forums

[resolved] theme designing breaking and I don't know why (11 posts)

  1. justustinin
    Member
    Posted 5 months ago #

    Hi All,

    I thought I'd try my hand at building a wordpress theme for a blog some friends and I are planning to start. I got the basics down (or so I thought) with the style sheet, header.php, index.php, sidebar.php, footer.php pages. Then I tried to break my nav off into a seperate php file and that's when I noticed the theme wasn't working. As soon as I added this the wordpress menu bar disappeared from the top of the screen as did any code following the code:

    <?php get_nav(); ?>

    I did a bit of testing and discovered it wasn't the actual contents of the nav.php that was causing the problem. In fact, if I added any <?php get_somepage(); ?> command this would cause the theme do deliver the same symptoms. I also moved the command around the code to see if it made any difference, tried embedding it within different Divs etc. None of this made any difference.

    I'm at a point now with trying to figure it out where I just can't figure out whats going wrong.

    I've been using the book WordPress Theme design as a guide to help me with what I'm doing. the book recommends building a html page with CSS. Then cutting it up into the different bits of a wordpress theme while using the Kubrick theme for the loop and other key bits of code.

    If anyone would be willing to take a look at the site and see if they can spot something obvious I'd really appreciate it. There's really nothign to the site at all at the moment as I'm just trying to figure out the design. The address is:

    I've taken out the line of code that breaks it because it kills the rest of the code from appearing in the source. So basically when it's there is terminates the code.

    Thanks for reading

  2. kionae
    Member
    Posted 5 months ago #

    I don't believe get_nav() is a valid WordPress function. It's likely throwing a PHP error that you can't see because you've got Debug turned off.

    You may be thinking of the wp_nav_menu() function...

    http://codex.wordpress.org/Function_Reference/wp_nav_menu

  3. Jonas Grumby
    Member
    Posted 5 months ago #

    If you want your menu to be in an external file, use a php include.

  4. justustinin
    Member
    Posted 5 months ago #

    Thanks for your quick response Kionae.

    Though I don't think this is the issue. I've tried a few left of field .php names which couldn't be wordpress functions and I still have the same problem. for example I created a page called nothingmuch.php that just contained <p>hello</p> and it still caused the same problem. So I think it's something quite fundamental in how I've cut up and put the thing together.

    I also tried renaming nav.php to navlist.php. Which didn't slove the problem.

  5. Jonas Grumby
    Member
    Posted 5 months ago #

    <?php include ('yourfilename.php'); ?>

  6. justustinin
    Member
    Posted 5 months ago #

    Thanks Jonas,
    I'll have a go at this and see how I get on. Forgive me if this is a stupid question but is <?php get_theNameOfAFile(); ?> not an include command?

  7. justustinin
    Member
    Posted 5 months ago #

    That Works Joans thanks!

    for future reference, can you tell me what the difference in
    <?php include ('nav.php'); ?>
    and
    <?php get_nav(); ?>
    is?

    Sorry, this is project is a php learning curve for me. I figured the filename and () would cause it to run the script in the named file like in C derived languages?

  8. Jonas Grumby
    Member
    Posted 5 months ago #

    I have never heard of get_nav and don't think it is valid code.

  9. justustinin
    Member
    Posted 5 months ago #

    OK, Thanks both of you. That solved the problem very quickly. Your help is really appreciated!

    thanks!

  10. kionae
    Member
    Posted 4 months ago #

    Just as an addendum...

    No, <?php get_theNameOfAFile(); ?> is not an include command. There *are* some functions within WordPress that have a similar format, (like get_sidebar(), for example)... but those are functions that are defined in the WordPress core code. It's not something that PHP automatically knows how to do.

  11. alchymyth
    The Sweeper
    Posted 4 months ago #

    another addendum:
    get_template_part() should also work instead of include - just with different syntax:
    http://codex.wordpress.org/Function_Reference/get_template_part

Reply

You must log in to post.

About this Topic