Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    I have hacked this functionality in to the code for one of my sites, I hope this helps you.

    Insert this into includes/location.class.php line 124

    $ml_cats = get_the_category();
    	        foreach( $ml_cats as $ml_cat )
    	        {
    	        	$categories[] = $ml_cat->term_id;
    	        }
    
    					$categories = array_merge(array('all'), $categories);
    
    	        $args['meta_query'][] = array(
    	            'key' => 'ml_advert_categories',
    	            'value' => $categories,
    	            'compare' => 'IN'
    	        );

    and includes/metaboxes.php line 31

    // categories
    	$categories = get_terms('category');
    	$all_categories = array();
    
    	foreach ($categories as $category) {
    		if($category->parent)
    		{
    			$parent = get_category( $category->parent);
    			$long_name = $parent->name . ' / ' . $category->name;
    		}
    		else
    		{
    			$long_name = $category->name;;
    		}
    
    		$all_categories[ $category->term_id ] = $long_name;
    	}
    
    	asort($all_categories);
    
    	$all_categories = array('all' => 'All Categories') + $all_categories;

    and then before the “Tag Archives *” section in the same file

    array(
    				'name' => 'Categories *',
    				'desc' => 'Select categories on which to display advert',
    				'id' => $prefix . 'categories',
    				'type' => 'multicheck',
    				'options' => $all_categories
    			),

    I tried this and I could select which categories I wanted etc. but when you go to the advert in question, there’s a big error code displaying above the ad at https://www.kmcharityteam.co.uk.gridhosted.co.uk/

    Warning: array_merge() [function.array-merge]: Argument #2 is not an array in /var/sites/k/kmcharityteam.co.uk/public_html/wp-content/plugins/ml-adverts/includes/location.class.php on line 133

    Line 133 is

    $categories = array_merge(array('all'), $categories);

    Never mind, I put the code in lcations.class.php under line 124.
    On line 124 is a ‘}’ so it was the wrong side of it. Once I moved the ‘}’ underneath the code that I placed in, everything now behaves.

    Thank you so much Andy Webb!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Feature] Show banner by category of post’ is closed to new replies.