PHP Classes

WordPress Term Post Count: Get WordPress terms and posts using them

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 127 All time: 9,381 This week: 555Up
Version License PHP version Categories
wordpress-post-count 1.2GNU General Publi...5.0PHP 5, Databases, Blogs
Description 

Author

This class can get WordPress terms and posts using them.

It can query WordPress database to query the taxonomy to get the posts that use a given term.

If the term has also a children terms, it can also query the posts of the children terms.

The list of posts to be returned may be filtered by post status.

Innovation Award
PHP Programming Innovation award nominee
August 2015
Number 9


Prize: SourceGuarding PHP encoder tool
WordPress is very popular blogging platform. Nowadays it can be used for many other purposes thanks to the many plug-ins that exist.

However when you want to integrate it with a separate application you need to write custom code to extract information in a WordPress blog.

This class can query the WordPress database directly to retrieve the list of posts that have certain associated terms.

Manuel Lemos
Picture of amani
  Performance   Level  
Name: amani is available for providing paid consulting. Contact amani .
Classes: 3 packages by
Country: Iran Iran
Age: 38
All time rank: 334565 in Iran Iran
Week rank: 420 Up4 in Iran Iran Up
Innovation award
Innovation award
Nominee: 2x

Example

<?php

/**
 * <name>Wordpress Post and Term count</name>
 * <author>Akbar Amani </author>
 * <email> amania1364@gmail.com </email>
 * <version>PostCount v1.0</version>
 * <url>webreference.ir</url>
 * <copyright> Copyright (C) 2014 GNU General Public License. All rights reserved. GNU/GPL</copyright>
 */

 
 
include_once("PostCount.php");

// send wordpress databse class to use in query
$terms = new PostCount($wpdb);

//set an id to get posts and terms
// 'publish' for published posts;
// '' for all posts
$status = '';
$terms->SetTermID(162, $status);

// get all post count (from all child terms)
$post_count = $terms->post_count();

// get all child term count
$term_count = $terms->term_count();

// get all posts id as array
$post_id_array = $terms->post_id_array();

// get all terms id as array
$term_id_array = $terms->term_id_array();

// get term child level
$term_level = $terms->$term_level;


  Files folder image Files  
File Role Description
Plain text file PostCount.php Class Class file
Accessible without login Plain text file sample.php Example class example

 Version Control Unique User Downloads Download Rankings  
 0%
Total:127
This week:0
All time:9,381
This week:555Up