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.

I am working on a website where I am specifying links to pages within my site in other pages.

I am using the same permalink post name structure i.e. http://example.com/sample-post on both development and production and I am using /index.php/sample-post/ to link to a specific blog. This works on production but not on development.

My development machine's wordpress install is under a directory called wordpress and is running off a URL http://127.0.1.1:8080/wordpress/

On development for some reason when I specify /index.php/sample-post the wordpress part of the site url is absent. This only seems to happen with posts and not pages.

As far as I know /index.php/ refers to the site url which should be http://127.0.1.1:8080/wordpress/ unless I am mistaken. Moreover I would like to know if there is any alternative way to specify absolute URLs in wordpress and get around this problem.

Thanks in advance. nav

share|improve this question

2 Answers 2

Suggestion:

I suppose that you have a backend interface that use custom fields to do this.

Don't use permalinks in this fields, instead save the post_id of the page that you want to link in the custom field and use get_permalink() in your code

Example: Custom field name: link_to_page

In your code, use, for example

echo get_permalink(get_post_meta($post->post_id,'link_to_page',true))

In the backend, you can use custom meta boxes. See this article for reference on how to implemente custom meta boxes

share|improve this answer
    
I am not using the link to the page in my code I am using it in my content. Hence, I cannot execute PHP code like echo get_permalink(); as you have suggested. I do not intend to use a plugin to do this either as the method detailed in the codex to linking pages should work the same on both development and production. –  navanitachora Apr 10 '12 at 1:44
    
Ok, use index.php/sample-post instead of /index.php in your code –  keatch Apr 10 '12 at 7:00
up vote 0 down vote accepted

Managed to work this out. I have posted the step on stackoverflow.

Hope it helps someone.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.