Insert php content from Wordpress Site

php
wordpress

(Martin) #1

I already now how to insert an hype Document in wordpress.

I also read the answer to a similar Question:

Since Wordpress allows you to create simple, bare bones templates that include just the ‘post content’ you can do this already by embedding the URL of those pages within HTML widgets in Hype.

I tried this with an HTML Widget in Hype. There I would need a code like
<?php the_field('list'); ?> or <?php the_content(''); ?>

But when I look in inspect element the Code looks like:

As you can see - the php is in a comment…

So could you help me how to insert such Code? Or a page.php file? I also tried this, but get only php Errors with undefined header…

http://wp4.able2create.com/hype-tests - klick on the round Button…

Thanks for your Help!
Martin


#2

The code for your page template cannot be inserted within an HTML widget as code – that creates an .html file within your Hype resources library. Your page template needs to be defined in your Wordpress theme. When you create a Page Template, you can select it as a ‘Template’ when composing a page within your Wordpress Post Editor.

You’ll need to create a new .php file within your Theme directory called something like page-hypeexample.php and use this code:

<?php /* Template Name: My Custom Page */ ?>

<?php get_header(); ?>

		<div id="primary">
			<div id="content">

				<?php while ( have_posts() ) : the_post(); ?>

					<?php get_template_part( 'content', 'page' ); ?>

					<?php comments_template( '', true ); ?>

				<?php endwhile; // end of the loop. ?>

			</div><!-- #content -->
		</div><!-- #primary -->

<?php get_footer(); ?>

Then, make a new page and select the custom template name defined in this file. Next, publish the page, and get the URL of that page and insert it within an HTML widget’s source URL.

This page explains how to create a Page Template: https://developer.wordpress.org/themes/template-files-section/page-template-files/page-templates/#creating-a-custom-page-template-for-one-specific-page


#3

Hi Martin, (@a2c)

http://www.dr-mac.co.uk/

Here I have embedded a page from a WP site inside a Hype document.

I have done essentially what Daniel has said but I have also adapted it to not show the header and footer of the WP site so it’s just the content but if you go to the page within the WP site directly you get the header and footer.

http://dr-mac.co.uk/wp/?page_id=4

If you want me to post a walkthrough. Let me know and I can upload a video tutorial.

D


(Martin) #4

Thank your very much for your fast and helpful reply!

It is working now! But I think the Problem was that I checked “Embedded HTML” instead of “Specified URL”.
Now I can see the Content instantly!!!

With Advanced Custom Fields in Combination there will be endless Possibilities!!!

I´m excited!

Thanks again for your Help!
Martin


(Martin) #5

Thank you very much for your Offer!

But I did it already on my own!

Anyway thanks for your offer!


#6

This would be super helpful, @DBear!


#7

I’ll try and get it uploaded tomorrow! :slight_smile: