November 6, 201510 yr 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!
November 6, 201510 yr 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 November 6, 201510 yr by Nillervision
November 7, 201510 yr Author Thank you so much. I was quite lost with that. I'll try it tonight. I will let you know how it goes!
November 9, 201510 yr 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