Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wordpress image gallery integrated on website

Featured Replies

Hi,

 

I am building this portfolio website wich has an image gallery where the owner can upload and remove images. I didn't want to make the whole website in Wordpress since i haven't used it much and the appearance needed to be quite custom so i thought it's easier for me if i just write it from scratch.

 

I was wondering. Google tells me it is possible to integrate parts of wordpress onto your site. Would it be possible just to make the gallery in wordpress and get it appear on the site? How would i go on doing this if it is possible?

 

Thank you!

It is possible. I have not tested this but from what I gather this would be the approach:

1. Install wp in a folder on your domain eg. yoursite.com/wp.

2. From the WP admin panel create the gallery that you want to include and insert it into a post and take a note of the posts id (The number at the end of the posts shortlink)

3. At the root level (or where you keep your static pages) create the file in which you want to include the wp posts. The file must have the .php extension

4. Create a php block at the top of the file in which you include the path to WP

<?php 
define('WP_USE_THEMES', false);
require('http://yoursite.com/wp/wp-blog-header.php');//replace this path with the path to your wp installation
?>

This is described in details here

5. Insert all the static mark up into your file

6. You will now need to insert a query for your post where you want it to be in your mark up. Since you just need a single post I don't think you will need a loop. You should be able to get the post like this:

<div class="yourGallery">
    <?php 
        $post_object = get_post( 15 );  //replace the number with your actual post id (you took a note of it in step 2)
        echo $post_object->post_content; 
    ?>
</div>

Details here

 

7. Finally you might want to edit your .htaccess to make sure that users can not directly access any pages generated by your WP installation (just google "htaccess redirect") and you should also disallow indexing of wp pages from search engines (This can be done either in the WP Admin panel, under "settings", or you can manually disallow indexing in a robots.txt file)

Edited by Nillervision

  • Author

Well looks like it kinda works but something missing.

 

I get "[gallery ids=1,2,3,4,5]" So that comes from the post.

 

But it does not show the images in the gallery.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.