0

Several pages are subs of main page account. Example: account\service.

How to goto specific page number including page title with permalink?

I have tried this:

$GLOBALS['create_page_service'] = '1281';
$out .= '<a href="'.get_page_link($GLOBALS['create_page_finder']).'">'.get_the_title($GLOBALS['create_page_finder']).'</a>';

Result is empty.

1 Answer 1

0

You're using the wrong index:

$GLOBALS['create_page_service'] = '1281';
# Your code uses 'create_page_finder' below
$out .= '<a href="'.get_page_link($GLOBALS['create_page_finder']).'">'.get_the_title($GLOBALS['create_page_finder']).'</a>';

$GLOBALS['create_page_service'] = '1281';
# my changed code uses 'create_page_service' below
$out .= '<a href="'.get_page_link($GLOBALS['create_page_service']).'">'.get_the_title($GLOBALS['create_page_service']).'</a>';

As an aside, I would avoid using globals whenever you can.

3
  • Result of your code is page: account Why? I am on account and want with this <a href> that visitor can go to the service page with that link. When I use get_page_link() I never get the subpage = 1281. That is what I do not understand and like to fix.
    – Hermants
    Commented Sep 28, 2015 at 13:55
  • If the Page with ID 1281 is indeed the service page, then it should work. Question: is the Service page an action "Page" in the WordPress sense or a "Post?"
    – phatskat
    Commented Sep 28, 2015 at 14:05
  • You're right. I did not copied correct the page ID. It was 12819! Now I get the correct page. Thanks for your reply.
    – Hermants
    Commented Sep 28, 2015 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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