I have set a custom page 'myblog' as 'Posts page' in 'Reading Settings', but why I always get the first post article of 'myblog' instead of 'myblog' itself?
var_dump(get_permalink()); // "http://xxxx.com/myblog/hello-world/"
It should be:
"http://xxxx.com/myblog/"
Any idea why and how I can fix this?
You can do something like this to get the permalink for your blog page (
page_for_posts
). Below has a couple conditionals checks for fallback, but really the callget_permalink()
on thepage_for_posts
option is what you need.