• This is an amazing plugin. I believe it will evolve to a really powerfull tool.

    Can someone explain how can i use the_terms field to change the category?

    I tried to use it like this, but did not work:

    <?php the_terms($post->ID,'category');?>

    Is this possible or do i have to write a new filter? If so, this is what i did, but didnt work either:

    // Handles the_category field
    class frontEd_category extends frontEd_basic
    {
    	function wrap($content, $separator, $parents)
    	{
    		if ( empty($content) )
    			$content = self::placeholder();
    		else
    			$content = str_replace('', '', $content);
    
    		return parent::wrap($content);
    	}
    
    	function get($post_id)
    	{
    		$cats = get_the_category($post_id);
    
    		if ( empty($cats) )
    			return;
    
    		foreach ( $cats as &$cat )
    			$cat = $cat->name;
    
    		return implode(', ', $cats);
    	}
    
    	function save($post_id, $cats)
    	{
    		wp_set_post_categories($post_id, $cats);
    
    		$response = get_the_term_list($post_id, 'category', '', ', ');
    
    		if ( empty($response) )
    			return self::placeholder();
    
    		return $response;
    	}
    }

    And this

    'the_category' => array(
    	'title' => __('Post category', 'front-end-editor'),
    	'class' => 'frontEd_category',
    	'argc' => 3,
    ),

    Thanks!

    https://www.ads-software.com/extend/plugins/front-end-editor/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter ricardormz

    (@ricardormz)

    I think what im looking for is being able to display:

    single_cat_title(); so i can edit the category right there.

    So you actually want to edit the title of a category, rather than the categories of a post, right?

    That might be doable. Stay tuned.

    Thread Starter ricardormz

    (@ricardormz)

    What i need to do is change the categorie of the post… Id number and all.

    With the help of your plugin im going to do a nice clean editor for posts in onprogress category. When the process of editing the post is done and ready (with some custom fields) to be published, i want to change the category to publicresult so it can be sorted in category-publicresult.php…

    So i want to actually change the category, not just the name.

    What i meant about using single_cat_title(); is that if i use the_category, it will display the category name as a link, and then wont be editable (i think).

    Thread Starter ricardormz

    (@ricardormz)

    Below is my working solution.

    Now this: the_category() displays the category link, double clicking links to site.com/?cat=#, so, i cant edit it. The same with tags (wich is cored). Im going to try to find a solution.

    Here is the frontEd_category class (or whatever its called):

    // Handles the_category field
    class frontEd_category extends frontEd_basic
    {
    	function wrap($content, $before, $after)
    	{
    		if ( empty($content) )
    			$content = self::placeholder();
    		return $before . parent::wrap($content) . $after;
    	}
    
    	function get($post_id)
    	{
    		$categories = get_the_category($post_id);
    
    		if ( empty($categories) )
    			return;
    
    		foreach ( $categories as &$category )
    			$category = $category->cat_name;
    
    		return implode(', ', $categories);
    	}
    
    	function save($post_id, $categories)
    	{
    		wp_set_post_terms($post_id, $categories, 'category');
    
    		$response = get_the_term_list($post_id, 'category', '', ', ');
    
    		if ( empty($response) )
    			return self::placeholder();
    
    		return $response;
    	}
    }

    The registration:

    'the_category' => array(
    			'title' => __('Post category', 'front-end-editor'),
    			'class' => 'frontEd_category',
    			'argc' => 3,
    		),
    Thread Starter ricardormz

    (@ricardormz)

    Doing this places the_category(); in a double-clickable <ul> area. Im going to keep with this solution until i find something else or someone can help me.

    $response = get_the_term_list($post_id, 'category', '<ul>');

    The only thing that i dont like about all this is that i have to be careful when writing the category name. A check-box feature in the future would be cool.

    To quote myself:

    As for editing categories, two reasons why it wasn’t added until now:

    – it would be really slow if you have a lot of categories
    – the interface takes up quite alot of screen space

    From here.

    what about to display a dropdown list?
    if it takes longer time to load.. o don’t care.. i think it will be really great to be able to change the category of a post.. indeed.. i need that too

    @ricardormz

    thanks a lot for your contribution.. i’m using it right now.. and works veeery good.. as it is .. it makes me happy..

    but its there only one thing that i dont know why happens..
    as i finish editing the plugin adding your lines of code.. i see that something else changes where the category appear..

    i dont know why.. but now.. just before the category appear “, ” (without the quotes)..

    why is that?.. i want to make them dissappear. (can i? what i have to change in the code?)

    Yes, thanks @ricardormz for your contribution.

    @cristiantacchi: I’ll be adding support for categories in the next version of the plugin, so hang tight. See this topic.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Front-end Editor] Use the_terms() to change the category’ is closed to new replies.