- This topic has 16 replies, 3 voices, and was last updated 6 years, 2 months ago by Tom.
-
AuthorPosts
-
January 29, 2018 at 4:13 am #482352Thomas
Is there a way to add a page containing php?
I want to add a contact page with email form.
I tried uploading the page (contact.php) to the theme folder, and the child-theme folder. However when I enter the url, it gives a 404 error.I could make a shortcode, but it will make my functions.php significantly larger and I hope to prevent that.
And what part of page.php should I edit?
Everything betweendo_action( 'generate_before_main_content' );
anddo_action( 'generate_after_main_content' );
?
(Ofcourse I won’t actually edit page.php, but copy it, in order to use the same template).January 29, 2018 at 9:17 am #482684LeoStaffCustomer SupportHi there,
What are you trying to achieve?
You might be able to add PHP using GP hooks and just target to specific page:
https://docs.generatepress.com/article/hooks-overview/
https://docs.generatepress.com/article/using-hooks-conditional-tags/Let me know if this helps.
January 29, 2018 at 10:08 am #482719ThomasUsing hooks with conditional tags probably will do the trick, but I’m not really enthusiastic about this solution. It would mean I have to write the entire code for this page in GP hooks;
I want to display an email form on a contact-page, this code already takes up around 120 lines and there is more to be added. Therefor I would prefer a solution where I can upload a page to wp-content or my child-theme and visit it via url/url/contact.php.
However, when I try this, I’m being referred to the 404 page.January 29, 2018 at 5:03 pm #483082TomLead DeveloperLead DeveloperYou could create a custom page template: https://developer.wordpress.org/themes/template-files-section/page-template-files/
That’s probably the best method ๐
January 30, 2018 at 4:05 am #483391ThomasA custom page template seems to be the way to go, thanks for pointing me in the right direction.
One more question. How can I remove the featured image / background color on this page?
This is the best result I had:
As you can see the background color still exists, and I’d like to remove it.
January 30, 2018 at 9:17 am #483720TomLead DeveloperLead DeveloperThe white background color behind the “Contact” title?
February 7, 2018 at 4:15 am #490262ThomasSorry for the late reply. We made our website available for the public and were very busy with that.
The white background is what’s supose to be there. Maybe the picture isn’t all that clear because I’m not using a featured image and in this case you only see the back-ground color/color-overlay of the featured image.
What I want is to remove the featured image, just like the 404/forums/member-pages have no featured image.
February 7, 2018 at 11:59 am #490697TomLead DeveloperLead DeveloperIs there any way you can link me to that page so I can take a closer look?
February 11, 2018 at 2:20 am #493438ThomasYes, I made an example for you.
I actually added a message to the page for you Tom.
Trying to explain what I want and what I’ve done so far.https://vespa-ciao.nl/beta/test/
Thanks for looking into this.
Best regards.February 11, 2018 at 8:46 pm #494011TomLead DeveloperLead DeveloperSo this is due to the page header being set globally to all pages.
We can likely use a filter to disable it when on these specific custom post types – would that work for you?
February 13, 2018 at 7:34 am #495320ThomasCertainly, that would work for me, can you tell me how I set this filter?
February 13, 2018 at 9:37 am #495457TomLead DeveloperLead DeveloperI just went to write the function, but we need a conditional so we only disable it on specific pages. I thought the page was a custom page template, but it doesn’t look like it.
Are you going to be disabling the page header on a lot of pages, or only a few?
February 13, 2018 at 10:06 am #495479ThomasHmm, strange? I did exactly as described in your link for making page templates.
The test-page I made for you is in my child theme directory and is called page-test.phpEdit:
Ok I find out why, my bad.
I forgot thetemplate name: ...
part on top of the page, my bad.
Now it is a template as supposed to.February 20, 2018 at 12:59 am #500892ThomasHi there,
Is it possible this topic lost your attention?
Still looking for a way to remove the featured image ๐I took another look at it and the page is now a template as supposed to.
So your initial idea to write the function for specific custom template pages should work.February 20, 2018 at 8:59 pm #501611TomLead DeveloperLead DeveloperSorry about that! Not sure how I missed your last reply.
Let’s try this:
add_filter( 'generate_page_header_options', 'tu_remove_page_header_template' ); function tu_remove_page_header_template( $options ) { if ( is_page_template( 'page-test.php' ) ) { $options['content'] = ''; } return $options; }
This assumes your custom page template is named: page-test.php
-
AuthorPosts
- You must be logged in to reply to this topic.