0

I am integrating a WordPress blog into my existing portfolio, test.mysite.com. The WordPress default twenty twelve blog appears on test.mysite.com/blog/. I want to integrate WordPress functionality into my existing portfolio, so I have created a page at test.mysite.com/blog.php. I just added the next/previous page functions to the blog page. My problem is that the next_posts_link() function does not return the correct URL.

URL FOR THE BLOG PAGE USING MY PORTFOLIO'S LAYOUT: "test.mysite.com/blog.php"

DESIRED "NEXT PAGE" URL (ASSUME THIS WORKS): "test.mysite.com/blog.php?paged=2"

URL CURRENTLY RETURNED (DO NOT WANT!): "test.mysite.com/blog/.php?paged=2"

URL OF THE DEFAULT WORDPRESS BLOG (WHICH I DON'T WANT USERS TO EVER SEE BECAUSE I WANT THEM TO SEE): "test.mysite.com/blog/"

How do I change the URL returned? I think my lack of fluency in WordPress, PHP, and regular expressions is making this much harder than it should be for me.

Also, I will probably need to change the previous_posts_link() URL too.

2
  • Sorry... you want this ""test.mysite.com/blog.php" but not this "test.mysite.com/blog/"? Or you want both to appear to be at "test.mysite.com/", maybe?
    – s_ha_dum
    Jul 6 '13 at 20:51
  • Let me clarify. I want "test.mysite.com/blog.php", not "test.mysite.com/blog/". Right now, ".../blog/" will take users to the default WordPress blog with the twenty twelve theme. What I'm trying to do is integrate the blog into my website's EXISTING layout. I'm just trying to add a new page to my website with WordPress's functionality.
    – user422318
    Jul 6 '13 at 22:49
0

I am going to assume you've got blog.php?page=2 working since you stated that's what you wanted. It seems like you might have to pull off a lot of magic to hide /blog/ from your users. Not sure why you want that, so I'm going to ignore that and just give you a solution that might work.

I don't see a function to grab the current page. If one exists, you could add one and then just hard code the nav links in your theme. You'll need a little logic to be sure you're not sending to a page that doesn't exist ( are you on the last page already? )

You could also parse the number off of the get_next_posts_link() to get the number and go from there. Something like

$parts=split('" >',get_next_posts_link());
$numparts=split('=',$parts[0]);
$number=$numparts[-1];

should do the trick.

should give you an array where item 0 is

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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