• I’m getting

    Warning: Missing argument 1 for get_category_link()

    when I try to use get_category_link in an array.

    <?php
    
    /*
    Plugin Name: Category Function
    Plugin URI: https://www.ihowd.com
    Description: This plugin expand category functions by adding expanding, collapsing and folding functionaility.
    Version: 1
    Author: Muhammad Haris
    Author URI: https://www.mharis.net
    */
    
    function catfunc()
    {
    	global $wpdb;
    	$tp = $wpdb->prefix;
    
    	if(!isset($iIDcount))
    	{
    		$iIDcount = 1;
    	}
    
    	$aCategoryName = $wpdb->get_results("SELECT term_id, name FROM {$tp}terms ORDER BY name");	
    
    	foreach($aCategoryName as $szCategories)
    	{
    		$aResult[$iIDcount] = array('id' => $szCategories->term_id, 'name' => $szCategories->name, 'url' => get_category_link($szCategories->term_id));
    		$iIDcount++;
    	}
    
    	$aPosts = $wpdb->get_results("SELECT {$tp}posts.id AS <code>id</code>, {$tp}posts.post_title AS <code>title</code>, {$tp}term_relationships.term_taxonomy_id as <code>catID</code>
    									FROM {$tp}posts, {$tp}term_relationships
    									WHERE {$tp}term_relationships.object_id = {$tp}posts.id AND
    									{$tp}posts.post_status = 'publish' AND
    									{$tp}posts.post_type = 'post'
    									ORDER BY {$tp}posts.post_date DESC");
    
    	foreach($aPosts as $szPosts)
    	{
    		$aResult[$iIDcount] = array('post_id' => $szPosts->id, 'post_title' => $szPosts->title, 'cat_id' => $szPosts->catID, 'url' => $szPosts->id);
    		$iIDcount++;
    	}
    
    	return $aResult;
    }
    
    echo '<pre>'	.	print_r(catfunc(), 1)	.	'</pre>';
    
    ?>

    What am I doing wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Warning: Missing argument 1 for get_category_link()’ is closed to new replies.