Viewing 3 replies - 1 through 3 (of 3 total)
  • If I understand you correctly…

    You can either use the plugin “Page Links To” which will let you specify a custom permalink.

    OR

    Under custom fields
    key: external-link
    value: whateverthelinkis.com

    Then, in your template

    <?php
    $meta = get_post_custom();
    if($meta['external-link'][0]) {
     $permalink = $meta['external-link'][0];
    } else {
     $permalink = get_permalink();
    }
    ?>

    Instead of calling the_permalink() just echo($permalink);

    ETA
    Theoretically, there is a filter for “the_permalink”. In which case, you could try adding this to your functions file (still specifying the permalink in the custom values section).

    add_filter('the_permalink', 'getExternalPermalink');
    function getExternalPermalink($permalink) {
     global $post;
     $meta = get_post_meta($post->ID, 'external-link', true);
     if($meta['external-link']) {
      return $meta['external-link'];
     }
     return $permalink;
    }
    Thread Starter cqsite

    (@cqsite)

    Thank you so very much. Will give this a go!

    Thread Starter cqsite

    (@cqsite)

    I guess I need some hand-holding with this:

    The PageLinksTo plugin is 100% brilliant, but cannot be integrated into Gravity Forms, so I have had to go the manual route.

    That said, I’ve tried your instructions, but I am obviously missing something.

    The posts have permalinks that are only taking the first letter of the custom field value, so instead of taking me to https://www.link.com, they direct me to cinnamonquill.com/testblog/w

    (See ex at: https://thecinnamonquill.com/testblog/)

    In order to get to this point, I did the following:

    Custom field created.

    Code added to loop.php + functions.php.

    Though I don’t fully understand:
    ‘Instead of calling the_permalink() just echo($permalink);’

    So my loop.php looks like this: https://pastebin.com/SPKpPgT3

    My functions.php: https://pastebin.com/t3hVnzKh

    Sorry for the trouble + thanks for the insight!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘External URL for Post Title Permalink’ is closed to new replies.