Jump to content

How to put Phaser game into wordpress site?


ekeimaja
 Share

Recommended Posts

So, I need to put Phaser game to WordPress static site. Theme is called Zerif lite.

I need to put game to big title -section, where is not possible to use widgets.

How can I make the game appear to this section? Where do I put my game folder structure? Or is this even possible to make?

Link to comment
Share on other sites

Hi, 

it's possible to integrate your gmae in WordPress. Check this page on my web site (click on button called "Zoop: Pick them all"). 

You have to:

  1. upload your game folder in a folder on your FTP (i put my games in a folder called "jeux" on WP root folder)
  2. In your WP page, go to "text" (not visual) editor, add a div container for your game.
  3. Then add a script tag at the end of page to start game.
Link to comment
Share on other sites

<div class="home-header-wrap">

<?php

	global $wp_customize;

	echo '<div class="header-content-wrap">';

		echo '<div class="container">';

?>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/game/phaser.js"></script>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/game/boot.js"></script>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/game/preload.js"></script>
<script src="<?php echo get_stylesheet_directory_uri(); ?>/game/game3.js"></script>


<div id="game">

  <script src="<?php echo get_stylesheet_directory_uri(); ?>/game/main.js"></script>

</div>
	
<?php
	echo '</div><!-- .header-content-wrap -->';
		echo '<div class="clear"></div>';

?>

</div>

Now it gives error

SyntaxError: expected expression, got '<'
Phaser.Loader.prototype.fileComplete()             phaser.js:71080
Phaser.Loader.prototype.xhrLoad/xhr.onload()  phaser.js:70672

Link to comment
Share on other sites

  • 5 years later...

Nowadays, I wonder about it as well. Anyway, you should also pay attention to the optimization of your potential wordpress resource, or to existing one. I know at least one great article related to WordPress website speed optimization, and you know what - almost all advises and tips they have written about, I've tried on my own wordpress site, and they really helped to make it maybe x1,5 faster.

Edited by millerz8
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...