Welcome Guest, Not a member yet? Register   Sign In
wordpress data in codeigniter project
#3

All you need to do is query the WordPress tables for the blog data. I'm not going to do all of the work for you, because that wouldn't be fair if this is an assignment, but here is a start:


PHP Code:
<?php if( ! defined('BASEPATH') ) exit('No direct script access allowed');

class 
Wp_model extends CI_Model {

    public $table_prefix 'wp';

    /**
     * Get all posts.
     *
     * No revisions or drafts are allowed
     *
     * You have to join the posts table with the term relationships table
     * in order to get the term taxonomy ID. Then you have to join the 
     * terms table because the term taxonomy ID is the term ID, which gives
     * you the slug and category name for the post.
     */
    public function get_all$selections NULL )
    {
        if( empty( $selections ) )
        {
            $selections '*';
        }

        $query $this->db->select$selections )
            ->from$this->table_prefix '_posts p' )
            ->join$this->table_prefix '_term_relationships tr''p.id = tr.object_id''left' )
            ->join$this->table_prefix '_terms t''tr.term_taxonomy_id = t.term_id''left' )
            ->where'p.post_type''post' )
            ->where'p.post_status''publish' )
            ->order_by'post_date''desc' )
            ->get();

        if$query->num_rows() > )
        {
            return $query->result();
        }

        return FALSE;
    }
    
    
// -----------------------------------------------------------------------


Reply


Messages In This Thread
RE: wordpress data in codeigniter project - by skunkbad - 01-13-2017, 10:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB