Ready to get started?Download WordPress


Main story link point to an external URL? (19 posts)

  1. jbickers
    Posted 9 years ago #

    Hi all,
    Is there anyway to make the main link at the top of the story - the link which points to that entry's page/comments/etc. - point to an external URL instead? I'm using my blog to maintain my clippings of articles I've written, and the body of the entry is being used to describe the article. So I'd like to be able to have someone click on the name of the article, and see the article itself on the external site.
    I've tried placing the link tag in the title field, but it doesn't work properly - seems to get confused right around the "> mark.
    Any help would be appreciated. Best,

  2. jbickers
    Posted 9 years ago #

    ... but I assume there's no way to do this on a per-post basis, i.e. without modifying the template? (Because there will be some posts which I want to behave "normally")

  3. charle97
    Posted 9 years ago #

    i use an if statement to segregate my link entries, which are in a link category, from my normal entries, which are not in my link category.

  4. jbickers
    Posted 9 years ago #

    Any chance you could post an example of how you do this, precisely? I've just looked at your site, and it looks like you're doing what I'm trying to do ...

  5. charle97
    Posted 9 years ago #

    you'll need to move all of your link type entries to category with id no 1. it's usually called general.
    then add the following functions to your my-hacks.php file.
    function the_ID_number() {
    global $id;
    return $id;
    function the_cat_id_number($postid=''){
    global $tablepost2cat, $wpdb;
    $catidno = $wpdb->get_var("SELECT category_id FROM $tablepost2cat WHERE post_id = '$postid' ");
    return $catidno;

    then you'll need to adapt "the loop" to your template:
    <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
    <?php $postidno = the_ID_number(); $catsidno = the_cat_id_number($postidno); if ($catsidno == 1) { ?>
    //code for link post
    <?php } else { // prints posts without excluded cat ?>
    //code for normal post
    <?php } // closes printing entries with excluded cats ?>
    <?php } } else { // end foreach, end if any posts ?>
    Sorry, no posts matched your criteria.
    <?php } ?>

  6. Michael Heilemann
    Posted 9 years ago #

    Does anyone have this running on 1.2?

  7. wujimon
    Posted 9 years ago #

    If there a template avaiable that shows this working for the default template? I'm a bit confused about the else clause. Wouldn't it also display the entries in the links category?

  8. charle97
    Posted 9 years ago #

    well it depends. if you're applying multiple categories to a link entry and you're not storing your links in category 1, then the else portion would display the entries in the links category. if your links only have one category, the links category, then the entries in the links category wouldn't be displayed by the else statement.

  9. Nick Momrik
    Posted 9 years ago #

    You could simplify it even more by making use of the function in_category. ;-)

  10. Anonymous
    Posted 9 years ago #

    Wouldn't it also work to just use the excerpt category as the criteria?
    If it's not null/empty, then create outside link... otherwise, spit it out like normal. I *think* the code might look something like this...
    if (the_excerpt_rss()){
    do outside link stuff...
    } else {
    do the regular stuff...
    --- regular code here ---

    As long as you *only* used the excerpt section for outside link URLs, This would allow you to have the functionality in any category right?
    - Kathy

  11. Nick Momrik
    Posted 9 years ago #

    For just that fact...then you cannot use the excerpt for anything else.

  12. Nick Momrik
    Posted 9 years ago #

    Matt has posted how he accomplished this...

  13. Anonymous
    Posted 9 years ago #

    Ok I just worked up an alternative. I wanted to be able to have linkblog style posts, on a per category basis instead of putting them all into a general links category. Using 1.2RC and the custom meta fields:
    - First I created a key named URL, and the value entered is a fully qualified website address (Including the http://)
    - Second I created a key name LB, and I'm using this like a toggle switch. In other words, if an entry is supposed to be for the "linkblog", I enter a value here of "Yes"
    Then, in my index.php page, just under divclass=storycontent, I made these modifications...

    <?php //testing
    if ($link[0]&&$LB[0]){ // if there's a link attached and LB is yes ?>
    » "><?php the_title(); ?><?php remove_filter('the_content', 'wpautop');
    the_content('Details...', '', ''); ?>
    <?php }else{ // do regular stuff ?>
    <b class="storytitle" id="post-<?php the_ID(); ?>">» " rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></b>
    <div class="meta"><?php edit_post_link(); ?></div>

    remove_filter('the_content', 'wpautop');
    the_content('Details...', '', '');
    <?php }//end else ?>

    Seems to be working well :) Thoughts? Foresee any future problems from it?
    - Kathy

  14. Nick Momrik
    Posted 9 years ago #

    With using in_category and something similar to Matt's implementation I can put a "link" post into multiple categories as long as one of those categories is the category for link posts. It saves the time from having to enter custom meta fields each time.

  15. Anonymous
    Posted 9 years ago #

    Good points actually...
    in_category gives me call to undefined function though. Which build was this included in and/or which file is it supposed to be in?

  16. Nick Momrik
    Posted 9 years ago #

    Oh...I think Matt just recently added it in the last few days.

  17. Anonymous
    Posted 9 years ago #

    Far as I can tell I've got the latest: May 14th

  18. Nick Momrik
    Posted 9 years ago #

    19th is the latest.

  19. Anonymous
    Posted 9 years ago #

    Bingo! I've been watching the dev blog for notes about updated releases... apparently that was wrong :)
    Thanks! (Got it working)

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.