2

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

2 Answers 2

1

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

2
  • 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.
    – nandac
    Commented Apr 10, 2012 at 1:44
  • Ok, use index.php/sample-post instead of /index.php in your code
    – keatch
    Commented Apr 10, 2012 at 7:00
0

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

Hope it helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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