0

I am trying to figure this out for weeks now. I added some custom endpoints to my woocommerce my-account page. All but one are linked with a shortcode and work fine. One should link to a normal wordpress page, showing it within the my-account page. I don't know how to program php and all it does for now is opening that page on a otherwise empty screen, not within the my-account page.

That's the code I came up with, but the part within the {} must be wrong (as it opens to https://new.holistic-horse-training.com/forum-links):

add_action( 'woocommerce_account_foren_endpoint', 'foren_content' );

function foren_content() {
    return $url = 'https://new.holistic-horse-training.com/konto/forum-links/';
}

Could please somebody tell me the correct code for showing that page in the window of my account? Here is a screenshot of the problem: https://new.holistic-horse-training.com/wp-content/uploads/2020/12/content-in-my-account-window-scaled.jpg

Thanks in advance!

Pascale

1 Answer 1

0

Check this one:

How to add a new endpoint in woocommerce

Update

In your callback function include your extended template page because output is expected.

ex:

function foren_content() {
    include('woocommerce/myaccount/custom-page.php');
}

Then inside custom-page.php call the desired content with get_post(ID) or if you have your endpoint registerd in woocommerce settings call it by slug.

The whole process of adding new endpoints is explained in this article with a great example using a class.

https://stackoverflow.com/questions/38039616/woocommerce-assigning-an-endpoint-to-a-custom-template-in-my-account-pages

Personally i would use the class shown in the article because it executes all necessary procedures and you have all the code in one place. I could elaborate on this here but is already explained in posted article.

Depends on the approach and version of woocommerce. The easiest way is to continue current approach. I think your question is a matter of stackoverflow. :)

Hope it helps. Regards

1
  • Thank you Roman, this is the link I followed and came as far as I did. But I could not find an example of calling a page via its URL and I really, really was searching the www.
    – PascaleK
    Dec 29, 2020 at 18:52

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.