Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.4k views
in Q2A Core by
retagged by
Greetings to everyone!

I need to create a new page in an existing q2a site, I don't want to use the admin panel to do this, just in a programming way. Must I do it using plugins? or using the advanced theme. I need to connect my new pages to the landing pages throught their links too.
Please tell me how can I do it step by step, because I was researching and this is not so easy...

Thank you so much!
Q2A version: 1.7.3

3 Answers

+3 votes
by
selected by
 
Best answer

As far as I understood you are looking a custom page in Q2A to display probably external content on it and set it as homepage on q2a site. Or you want to create a custom page in q2a for some purpose programmatically not through Admin > Pages to display any logical or custom content on that page.

If I am correct and you have any of the above scenario, you can make a custom page module in the plugin and set the request part for your page.

Then you can directly access your page via URL and no need to create any page in Admin area. I am using this technique in my upcoming plugin.

I have created Gist for you. This is a kind of boilerplate and you can straightly use to create your plugin.

Let me know how is that for you!

Q2A Market Gist

by
Thank you so much Jatin, I think is a excelent answer for me, because I'm starting to work with q2a framework!
by
+2
I really glad to know that my few minutes of effort works for you..... :)
+3 votes
by
Unfortunately it's not very easy to do that, the Q2A code for making a new page has quite a few different things that need to be done.

Take a look at the code here from line 253: https://github.com/q2a/question2answer/blob/dev/qa-include/pages/admin/admin-pages.php#L253

That's basically what you'd need to do yourself. To access Q2A from another script, take a look here: http://docs.question2answer.org/code/external/

Once you have "connected" you can add new pages using the code from the first link.
+2 votes
by
As Jatin says: "you can make a custom page module in the plugin and set the request part for your page."

See examples in my open source plugins: https://github.com/q2apro?tab=repositories

Search for *page.php to see the code and check the qa-plugin.php how to register a page module.

This is plugin is a good starting point:

https://github.com/q2apro/q2apro-find-text-posts

Copy it and modify the relevant parts to your needs.
...