Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Wordpress Custom Fields

Options
  • 14-06-2010 5:34pm
    #1
    Registered Users Posts: 1,453 ✭✭✭


    Hey,

    I recently set up a website for a friend. It's a phpBB3 based forum. The forum is located at domain.com/phpBB3.

    When you just go to domain.com, we created a wordpress site with all the latest news related to the topic. The wordpress theme (arthemia) has about ten post excerpts on the homepage, the user can then click on "read more" to read the rest of the post, still on the wordpress end of the site.

    What I am trying to do is create a custom field in wordpress called "forum_link" and when creating each post on wordpress, add the custom field and add a link to the post being discussed on the phpBB3 end of the site.

    Basically I only want to use the homepage of the wordpress site, and have all the links go to the phpBB3 end. User goes to domain.com, sees a story they're interested in, clicks on "read more", or the image, or the post titles, and is directed, using "custom fields" (i think!) to the relative discussion on phpBB3. This link can be specified at the time of writing the w/p post.

    The code for the "read more" link is below.

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">Read the full story »</a>

    Does anyone know what I should change that to so wordpress will set the link to be the custom value "forum_link"

    Thanks a million for any help ye can give me. I tried google and got some help but couldn't quite figure it out.

    Thanks again


Comments

  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    I've written a Basics of WordPress Custom Fields article that should help you out

    What you want to do is get your custom field e.g. "forum-thread-url" and replace the permalink URL "the_permalink()" with the link based on your custom field if it exists.

    If you use the code from the example in the post above then something like
    <a href="<?php echo $themeta; ?>" rel="bookmark" title="Link to the forum thread">Read the full story on our forum &raquo;</a>
    
    will do.


  • Registered Users Posts: 1,453 ✭✭✭spartacus93


    Hey Trojan

    Thanks a million for your response. Your blog article was extremely helpful!

    In the end (after much head - scratching!) I used this

    <a href="<?php $values = get_post_custom_values("custom"); echo $values[0]; ?>" rel="bookmark" title="Read the full story on our forum">Read the full story on our forum »</a>

    and it works perfectly.

    Thanks again for you help.


  • Registered Users Posts: 16,413 ✭✭✭✭Trojan


    Hey Trojan

    Thanks a million for your response. Your blog article was extremely helpful!

    Glad to hear it!
    In the end (after much head - scratching!) I used this

    <a href="<?php $values = get_post_custom_values("custom"); echo $values[0]; ?>" rel="bookmark" title="Read the full story on our forum">Read the full story on our forum »</a>

    Just a word of warning - this will work, and *probably* should always work, but what you are doing there is grabbing the first custom value (i.e. $values[0]).

    You are saying "give me the first custom value", you are not saying "get the value for the forum_link". That will continue to work until you or someone else adds another custom value which may then break the link.

    HTH.


Advertisement