Adding new pages (for navigation menu)

Discussion in 'WordPress' started by FunkyFresh, Jun 16, 2010.

  1. #1
    in order to show a page in the navigation bar, does it have to be added from the admin dashboard or can it I just upload the page to the current theme folder.

    For example, can I just write code in the ‘header.php’ to get ‘porfolio.php’ without having that page added under the admin dashboard>add page
     
    FunkyFresh, Jun 16, 2010 IP
  2. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #2
    Yeah you can add your own links to the navigation without going through the dashboard, I did it with an HTML page in header.php, but php should work. I forget the exact process, but you can copy the original php page into notepad and experiment. But why would you want to exclude it from the dashboard? It will be harder to make any changes to it.
     
    bob25, Jun 16, 2010 IP
  3. FunkyFresh

    FunkyFresh Peon

    Messages:
    499
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    well to start off, my nav bar is very customized in the sense that I need a <li id="something"> for each one of them. You are right, i guess i can write a whole page including any html in the dashboard>page.

    Back to the problem, I cant use direct html links as they would be wp-content/theme/testingtheme/ and that wouldnt look professional plus the fact that WordPress wont let me do that. Any chance you can tell me the code you used?

    thanks
     
    FunkyFresh, Jun 16, 2010 IP
  4. FunkyFresh

    FunkyFresh Peon

    Messages:
    499
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I just need to know how to display the links for custom pages?
     
    FunkyFresh, Jun 17, 2010 IP
  5. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #5
    As far as I remember it looked like this, but I used it a while back so I'm not to sure how it works.

    <li><a rel="nofollow" href="<?php echo get_option('home'); ?>"><?php _e("Home", 'studiopress'); ?></a></li>
    <?php wp_list_pages('title_li=&depth=4&sort_column=menu_order'); ?>
    <li><a href="YOUR URL">YOUR LINK NAME</a></li>
     
    bob25, Jun 17, 2010 IP
  6. getxposed

    getxposed Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It's very simple.
    Wordpress will scan the contents of all the files in a Wordpress theme to see
    how it all hangs together. When Wordpress sees the following code:-
    <?php
    /*
    Template Name: TEMPLATE-NAME-GOES-HERE
    */
    ?>
    ...then it knows it's a page template.

    So create a file and call it something like, newpagetemplate.php

    Then upload to your WP template folder

    Next go to your Page Editor in WP you'll see the file, newpagetemplate.php, click on it and call it what you want.
    SAve and update. Then check your home page you should see the page you just named on the side bar. If all looks good
    then go back to your template page via the WP editor again and anything below that php code you can add any HTML file
    you want (don't forget to use absolute URLs for the images) The new page should now show up on your WP Blog!
     
    getxposed, Jun 18, 2010 IP
  7. bvraghav

    bvraghav Member

    Messages:
    123
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    33
    #7
    First questions first.
    In order to add a node to your navbar, (add another page there), add a code like this, to the top of your header page
    <?php
    
    $my_page_name = ""; // write your page title here within the quotes
                     // remember that you should use \" instead of ", 
                     // if it occurs in your title, within the quotation marks
                     
    $my_link_text = ""  // write the link text here if it is different from the page name
                     
    if (!$my_link_text )
    	$my_link_text = $my_page_name;
    $my_page = get_page_by_title( $page_name );
    $my_url = get_permalink( $my_page->ID );
    
    ?>
    Code (markup):


    Below is how you can implement it to your navbar
    <ul>
    	<li><a href="#1">Page 1</a></li>
    	<li><a href="#2">Page 2</a></li>
    	<li><a href="#3">Page 3</a></li>
    	<li><a href="#4">Page 4</a></li>
    	<!-- new entry -->
    	[COLOR="Red"]<li><a href="<?php echo get_permalink( $my_page->ID ); ?>"><?php echo $my_link_text; ?></a></li>[/COLOR]
    </ul>
    Code (markup):


    Personally, I would call it a page only when it is added to the cms. Rest of them (like adding some portfolio.php) would be external pages. However, I can't figure out why would you want to not include this page in the database (or not save it through the admin dashboard) except for if you want it to look totally different from the rest of your site.


    Hope this works :)
    ---
    the sum of a whole is different from the sum of it s parts
     
    bvraghav, Jun 19, 2010 IP
  8. FunkyFresh

    FunkyFresh Peon

    Messages:
    499
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Thanks, the code is perfect and exactly what I needed.
     
    FunkyFresh, Jun 20, 2010 IP
  9. solutionman

    solutionman Peon

    Messages:
    73
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Thank it help me too.....
     
    solutionman, Jun 20, 2010 IP