• Resolved jbadger

    (@jbadger)


    I’m a noobie to WordPress, but I’ve implemented a news blog that runs under two different websites with two different URLs – but its the same newsblog. I use a virtualhost to direct both URLs to the correct directory, and then I use PHP to check which URL is being used in order to change the appearance of the theme accordingly (different theme graphics and different site nav).

    The problem is that there is only one URL that wordpress can know about for the purposes of previous_post_link and next_post_link. I want to be able to get the URL string from each of these before displaying and replace a string within the URL appropriately. The problem is that there is no non-displaying version of these two functions.

    To clarify, here are the two sites:

    1. news.pandesa.com – this is the site that wordpress knows about

    2. news.sharevault.com – wordpress doesn’t know about this one

    note that I have not been able to implement “next” and “previous” links in the latter case because of the problem stated above. If I were to have implemented these, the result would be that the user would bounce over to the other site when clicking ‘next’ or ‘previous’.

    … So my question is this: Is there another way, using PHP, to figure out the URL of the next and previous post?

    Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Add a filter on ‘post_link’. Change the URL there.

    Like so:

    function fixup_permalink_domain($url) {
    if (URL is supposed to be news.sharevault.com) {
    return str_replace('news.pandesa.com','news.sharevault.com',$url);
    } else {
    return $url;
    }
    }
    
    add_filter('post_link','fixup_permalink_domain');

    You’ll have to edit the if statement to check which domain it is supposed to be in.

    This can be added to your theme’s functions.php file. It will change all the post permalinks to the correct domain.

    Thread Starter jbadger

    (@jbadger)

    Worked like a charm! THANKS!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Need non-displaying alternative to previous_post_link and next_post_link’ is closed to new replies.