I am integrating a WordPress blog into my existing portfolio, test.mysite. The WordPress default twenty twelve blog appears on test.mysite/blog/. I want to integrate WordPress functionality into my existing portfolio, so I have created a page at test.mysite/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/blog.php"
DESIRED "NEXT PAGE" URL (ASSUME THIS WORKS): "test.mysite/blog.php?paged=2"
URL CURRENTLY RETURNED (DO NOT WANT!): "test.mysite/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/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.
I am integrating a WordPress blog into my existing portfolio, test.mysite. The WordPress default twenty twelve blog appears on test.mysite/blog/. I want to integrate WordPress functionality into my existing portfolio, so I have created a page at test.mysite/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/blog.php"
DESIRED "NEXT PAGE" URL (ASSUME THIS WORKS): "test.mysite/blog.php?paged=2"
URL CURRENTLY RETURNED (DO NOT WANT!): "test.mysite/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/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.
Share Improve this question edited Jul 6, 2013 at 22:54 user422318 asked Jul 6, 2013 at 20:40 user422318user422318 1011 bronze badge 2- Sorry... you want this ""test.mysite/blog.php" but not this "test.mysite/blog/"? Or you want both to appear to be at "test.mysite/", maybe? – s_ha_dum Commented Jul 6, 2013 at 20:51
- Let me clarify. I want "test.mysite/blog.php", not "test.mysite/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 Commented Jul 6, 2013 at 22:49
1 Answer
Reset to default 0I 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