Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

A little information: I am developing a one page theme that uses posts as sections on the main page. I have created code that allows users to add a menu item in the post page from a meta box when they create a section and it then creates a special ID for the section and adds it to the post and also creates a menu link for each section that has been given a name. The reason for this is because I plan on having the menu link move directly to that section when it is clicked.

So here is the dilemma: My code loops through each section and adds only the ones that have been given a custom name to the menu, just like it should. The problem though is that it is adding the website URL into the header link along with the url it has been given.

This is how it should appear: #SectionTwo

This is how it appears: mysite.com/#SectionTwo

I am not sure what exactly is adding this, I don't think it is my code for this but I will include it anyways. Does anyone have any ideas to what the issue could be?

<ul>
    <?php
        $lastposts = get_posts('numberposts=5&orderby=rand&cat=-52');
        foreach($lastposts as $post) :
        setup_postdata($post); ?>

        <li<?php if ( $post->ID == $wp_query->post->ID ) { echo ' class="current"'; } else {} ?>>


<?php if(!esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) == NULL) ) : ?>

    <a href="#<?php echo esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) ); ?>"><?php echo esc_attr( get_post_meta($post->ID, 'newtheme_section_id', true) ); ?></a>

        </li>
<?php endif; ?>

    <?php endforeach; ?>

</ul>
share|improve this question
    
Is the URL from your source code or just a DOM inspector? –  toscho Apr 22 '13 at 1:38
    
I am not 100% sure what you mean. If you are talking about when I mentioned that I don't think it is my source code, I actually meant this code I posted. I was thinking it was a rewrite issue, but I might be wrong. I am pretty new to php and wp development. –  user1632018 Apr 22 '13 at 1:42
    
<a href="#foo"> will be shown as <a href="http://example.com/#foo"> by a browser. Did you see the long URL in your source code? –  toscho Apr 22 '13 at 1:46
    
ahh okay I understand. It is a short URL in the source code and a long URL in the browser. –  user1632018 Apr 22 '13 at 1:58
    
That’s normal, not a problem. –  toscho Apr 22 '13 at 1:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.