WordPress.org

Ready to get started?Download WordPress

Forums

Adding Links to HTML pages (3 posts)

  1. jbelsher
    Member
    Posted 1 year ago #

    I am new to wordpress, but found an awesome tutorial on lynda.com for creating a blog page within a pre-built site. I am using DreamWeaver CS6 and have created what lynda.com calls a child theme, however, I cannot get the links to link to the proper folder. Here is the the PHP that I have put into my functions.php within this child theme:

    <?php
    function siteRoot($theFolder) {
    	$home = get_home_url();
    	// strpos(string, substring)
    	$thePosition = strpos($home,$theFolder);
    	// substr (string, start, length)
    	$thePath = substr($home, 0, $thePosition);
    	return $thePath;
    } ?>

    Then I have this code in my header.php file:
    < li id="home"><a href="<?php echo siteRoot('blog'); ?>index.html"><h1>Custom Suits Dallas</h1></a></li>

    This issue is that when I follow the links, it takes me to localhost://suits_index.html
    but, it should link to:
    localhost://suits_blog/index.html

    Is there a way to correct the siteroot folder within wordpress? Is my code wrong? Have I taken a wrong path to linking my prebuilt site? Any directiion would be greatly appreciated.

    Thanks,
    James B

  2. Beee
    Member
    Posted 1 year ago #

    I never built anything locally so no experience there, but does home_url() don't work in this case ?

  3. hardahmed
    Member
    Posted 1 year ago #

    I am new to this too but I got a similar issue but found out that if you change the Page properties of the header.php and change the document type to XHTML 1.0 Transitional the codes work. Mine was in HTML5 document type. As for your issue also just try changing the 'blog' to 'suits_blog' in your code.
    < li id="home"><a href="<?php echo siteRoot('suits_blog'); ?>index.html"><h1>Custom Suits Dallas</h1></a></li>
    Hope that helps.
    Thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.