• Resolved jaseemts

    (@cooljaz124)


    Hi,

    Does anyone know how to add custom meta field in Categories ? Like, When I make a new category, there should be 2 additional fields

    – Icon , where we add url of icon image of that category.
    – Check Box to set that particular category “POPULAR”

    See the screenshot of the functionality I have asked help for.

    Thanks in advance.
    Jaz

Viewing 10 replies - 16 through 25 (of 25 total)
  • Joseph

    (@jpe24524)

    I’m referring to the filter I mentioned about changing the display of wp_list_categories, not the plugin hack.

    Since the filter method won’t work, do you want the list to be flat or multilevel? Do you want it to have options like wp_list_categories?

    We can do a simple loop or extend wp_list_categories depending on what you want.

    Thread Starter jaseemts

    (@cooljaz124)

    Oops. Got you.

    May be we can go the simple loop way.

    Joseph

    (@jpe24524)

    Alright, so it’ll be flat, ie not multileveled for child categories?

    Thread Starter jaseemts

    (@cooljaz124)

    You should have correct view if you have a glimpse on the website.

    Take a look at — LINK REMOVED — , and place the mouse over “POSTS” nav which will give you the dropdown.

    The drop down shows – specific categories listed under posts. You can see how each category is styled. For the category checked “popular”, I may need to change the style, may be change the color to red.

    PS : This is all part of drag and drop of categories, as user can control which all posts they need to see. Made based on cookies.

    Joseph

    (@jpe24524)

    Ok, this should do the trick:

    function custom_list_categories() {
    	global $wpdb;
    	$popular = $wpdb->get_results("SELECT terms_id FROM wp_termsmeta WHERE meta_key = 'popular'", OBJECT_K);
    
    	$categories = get_categories();
    	foreach ($categories as $category) {
    		if ( isset( $popular[$category->term_id] ) )
    			$class = ' popular';
    		else
    			$class = '';
    		?>
    		<li id="category-<?php echo $category->slug; ?>">
    			<span class="category-name<?php echo $class; ?>"><?php echo $category->name; ?>
    				<div class="left"></div>
    				<div class="right"></div>
    			</span>
    		</li>
    		<?php
    	}
    }

    Call the function inside <ul></ul>.

    Thread Starter jaseemts

    (@cooljaz124)

    @joseph,

    Thanks a lot. I will be trying to implement this once I am back at my work PC.

    BTW, your site looks great ! May I know which Photo Gallery plugin you used there ? Love the way its organised into folders and subfolders.

    Also, I am not able to find your contact info anywhere. Let me know. Thanks again.

    Joseph

    (@jpe24524)

    Thanks. I’m using Nextgen Gallery with a fair bit of customisation, implementing categories and year by linking it with custom post type.

    I’ve been redesigning my site so I haven’t put up any sort of contact yet. It’s just a personal site so contact info isn’t of high priority.

    Thread Starter jaseemts

    (@cooljaz124)

    Thanks again. I will be updating the reply once I playing around with the codes you gave. ??

    Thread Starter jaseemts

    (@cooljaz124)

    Thank you so much Joseph for the help. It worked, very well ?? Glad that you helped.

    Hello,

    I made a new version (1.2.3) of the “category meta” plugin to include you “check-box” type.

    Regards,
    Eric

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘How to add Meta-Field in Categories ?’ is closed to new replies.