How to integrate wordpress blog into my site - php

I have a website using HTML & bootstrap and I want to add my blog to this site. I want to keep all my design the way it is, including my navigation. I don't want users to go to my WordPress page. Instead, I just want to integrate the blog part (adding the full blog from WP into my site).
My understanding is that I need to use the Loop to integrate it, but I am having trouble. Can someone please help me? Currently, I'm using the code below, but it cuts off each blog from the beginning and it's not showing the full posts:
<?php require('../wordpress/wp-blog-header.php');?>
<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php endforeach;?>
There must be a way to show my full blog posts on my site. Any help would be appreciated!!

So I figured it out after reading and reading lol.. here's the solution. It was very simple.
All I needed was to replace:
<?php the_excerpt(); ?> with the content <?php the_content(); ?>

Related

Editable posts WordPress

I'm trying to create my own template in CMS WordPress. I would like to have live editable text on my page http://restaurant.g6.cz/. I want to create something like posts and edit them from the web, because I can't think of anything better. I tried to paste into (page.php) something like
<?php
$my_post = get_post(168);
echo $my_post->post_content;
?>
and tried edit the text with plugin Live Editor but I wasn't successful, so I tried to write
<?php query_posts('cat=5&showposts=1'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
<?php wp_reset_query(); ?>
this was editable but every post needed it's own category. Does anyone know, how to do this in PHP or better way without plugins? Thank you all very much :)
Example

How do you integrate comment plugin from your wordpress into your blog.php HTML page?

I've read, watched so many articles and videos and just can't seem to put my hands on one thing. Any help would be appreciated.
So here it goes..
I have a wordpress blog and that has been integrated into my website in the blog.php, so that people can see my blog from my website instead of being linked to wordpress.. I wanted my clients to post comments from my blog.php site and currently it's only showing the default comment_form part(which is too big and not what I wanted) So I installed comments plugin called "DISQUS", but currently it's only showing up on my wordpress page and not my website at blog.php.
Could there be a php code that I'm missing to post on my blog.php?
So far this is what I have on the top of the blog.php page
<?php require('../wordpress/wp-blog-header.php');?>
and where I'm showing my blog part
<?php require('../wordpress/wp-blog-header.php');?>
<?php get_header();?>
<?php $posts = get_posts('numberposts=10&order=orderby=post_date'); ?>
<?php foreach ($posts as $post) : setup_postdata( $post ); ?>
<?php the_title(); ?>
<?php the_time('m/d/y') ?>
<?php get_footer(); ?>
<?php the_content(); ?>
<?php comment_form(); ?>
<?php endforeach; ?>
So am I missing something here? Should I be changing comment_form into something else? Or am I completely off?
Thanks Everyone.

Show readmore in wordpress post

In wordpress Twenty Eleven theme how to show read more after one post without writing any <!--read more--> in post page
Go wordpress admin panel and click reading under reading, choose summary instead of full text. That will help you.
Dashboard --> Settings --> Reading and click on "Summary" instead of "Full text"
EDIT:
The above settings for feeds. for showing in the home page, While you adding post put your cursor where you want to add "more" tag and then click Alt+Shift+T or click the button left to spell checker it will insert a more tag on your posts. I think this might work..
use the_excerpt() function in your post and add filter excerpt_more and add readmore.. link.
here this blog uses same function which is develop by me [Latest smartphone apps][1]
[1]: http://latestsmartphoneapps.com here on index page all post summery is given and readmore.. link is given which then display full post.
If you want such functionality let me know.
Use this code for Excerpt.
<?php query_posts('cat=ID'.'&showposts=NO. OF POST') ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h3><?php the_title(); ?></h3>
<?php the_post_thumbnail(); ?>
<p><?php echo substr(get_the_excerpt(), 0,65).' [...]'; ?></p>
Read More...
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php endif;?>
The a look at the_excerpt

How can I include Wordpress posts in a custom PHP file?

This is what i want to do:
I want /summary.php to include 5 latest posts (only the extract) from my blog, which lives in /wp.
Is there any way to include Wordpress in /summary.php and only print the html for these posts? (Maybe i should parse the rss?)
Take a look to Integrating WordPress with your Website
This is an example from that page, that shows the first ten posts in alphabetical order:
<?php
require('/the/path/to/your/wp-blog-header.php');
?>
<?php
$posts = get_posts('numberposts=10&order=ASC&orderby=post_title');
foreach ($posts as $post) : start_wp(); ?>
<?php the_date(); echo "<br />"; ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<?php
endforeach;
?>
Use $posts = get_posts('numberposts=10'); if you want the 10 latest posts.
Probably the easiest and most elegant way to do this is to create a custom theme to live on summary.php. The WP library exposes a number of functions for easy output of articles.
I think you have answered your self their. The RSS feed will give you the content of your latest posts.
With not much work you can just pull out the data you need
You can create a "clean" template, which you can apply to 'summary' page (this page must be a wordpress page too).
You can find an example here:
http://www.tyssendesign.com.au/articles/cms/fetching-posts-in-wordpress-expressionengine-with-jquery-ajax/
you can include wp-config.php, which will pull in the rest of the API. then you will be able to use wp functions like
function get_post($postID)

WordPress: How to display only posts that are in a certain category?

I'm pretty new to WordPress but have spent some 50 odd hours studying up on it, trying things out and such and have the feeling I got a pretty good handle on it now..
However the one thing I simply cannot get working is to have a page spit out a list of posts of a certain category.
Here is my example: http://dev.jannisgundermann.com/zoeikin/graphic-design/typographic-posters
I have a post that if I go to it directly works correctly, but does not show up on this page.
The post direct link.
The category id is '3' while the category name is 'typographic-posters'.
I have a custom page template for the typographic-posters page that looks like this:
<?php
/*
Template Name: Typographic Posters
*/
?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php if (in_category('3')): ?>
<div class="post">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<div class="post-description">
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>
</div>
<?=get_image('flutter-image');?>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</div>
<?php endif; ?>
<?php get_footer(); ?>
Using this code however the page only shows gets the header, sidebar and nothing else..
If someone could help me out that would really help me get a handle on this filtering of wordpress categories.
Thanks for reading,
Jannis
in_category will only work outside of the loop on a single page. I suggest using the query_posts function to solve this problem. You may use query_posts('cat=3') or query_posts('category_name=typographic-posters') to get the posts you are looking for.
Once obtained, just use the normal WordPress loop to access these posts.
The easiest way is to create a file called category-3.php and use the standard code from normal index.php or category.php file. Wordpress will take care of fetching posts only from category with id=3 and it's child categories.
in_category will only work outside of the loop on a single page. I
suggest using the query_posts function to solve this problem. You may
use query_posts('cat=3') or
query_posts('category_name=typographic-posters') to get the posts you
are looking for.
Once obtained, just use the normal WordPress loop to access these
posts.
This worked excellent, but make sure that you go into Settings > Reading and set the posts page to the -- Select -- option or it will override this query and dump all recent posts there regardless of category.
Simply add before the loop:
<?php query_posts="cat=3&showposts=5">
This will force the loop to display 5 posts (showposts=5) from category 3 (cat=3).
I would 2nd Eimantas' suggestion. The Template Hierarchy will use the category-3.php to display posts in that category. Usually you can just copy a theme's index.php or category.php to category-3.php and adjust that template for any customization you need. Plus the category template will better support pagination of posts.
But if you need to stick with a Page to display those posts, also see the Page of Posts example.
http://codex.wordpress.org/Template_Tags/query_posts
Just so you know where these answers are coming from...there are a lot more interesting functions you can do with query_posts as well.
This plugin could also help you if you want to be able to change the displayed categories without going through the code :
http://wordpress.org/extend/plugins/advanced-category-excluder/
I have filtered post by category Id using the method below:
query_posts('cat=1&showposts=3');
if (have_posts()) : while (have_posts()) :
// if(1) {
//echo the_category_ID();
the_post();
/**
* The default post formatting from the post.php template file will be used.
* If you want to customize the post formatting for your homepage:
*
* - Create a new file: post-homepage.php
* - Copy/Paste the content of post.php to post-homepage.php
* - Edit and customize the post-homepage.php file for your needs.
*
* Learn more about the get_template_part() function: http://codex.wordpress.org/Function_Reference/get_template_part
*/
$is_post_wrap++;
if($is_post_wrap == '1') {
?><div class="post-wrap clearfix"><?php
}
get_template_part('post', 'homepage');
if($is_post_wrap == '3') {
$is_post_wrap = 0;
?></div><?php
}
endwhile;
else :
get_template_part('post', 'noresults');
endif;
thank you for sharing on your thought its a great thought. Usually you can just copy a theme's index.php or category.php to category-3.php and adjust that template for any customization you need

Categories