WordPress.org

Ready to get started?Download WordPress

Forums

Hikari Category Permalink
How to use Hikari Category Permalink Plugin on Custom Post Types (2 posts)

  1. mmx0
    Member
    Posted 2 years ago #

    This file:
    wp-content/plugins/hikari-category-permalink/hikari-category-permalink-core.php

    contains this function: public function insertPostJS (see full function below)

    You have to go to the edit Post interface in WordPress and find the div id from the html that contains the taxonomy selection box.

    Add more lines as shown below that start with -- echo "<script type ....
    and add your div id as shown below.

    MMX

    public function insertPostJS(){
    if(!$this->isScategoryActivated){

    $url = $this->plugin_dir_url . '/scategory_permalink.js';
    echo "<script type=\"text/javascript\" src=\"$url\"></script>\n";

    global $post;

    $categoryID = '';
    if($post->ID) {
    $categoryID = get_post_meta($post->ID, '_category_permalink', true);
    }
    echo "<script type=\"text/javascript\">jQuery('#categorydiv').sCategoryPermalink({current: '$categoryID'});</script>\n";

    echo "<script type=\"text/javascript\">jQuery('#events_categoriesdiv').sCategoryPermalink({current: '$categoryID'});</script>\n";
    echo "<script type=\"text/javascript\">jQuery('#faq_categorydiv').sCategoryPermalink({current: '$categoryID'});</script>\n";
    }
    }

    http://wordpress.org/extend/plugins/hikari-category-permalink/

  2. mmx0
    Member
    Posted 2 years ago #

    Two more changes to make this work well ...

    In file: wp-content/plugins/hikari-category-permalink/hikari-category-permalink-core.php
    Comment out the following line and replace it with the one below using the "wp_get_object_terms" function. you must add your own taxonomy slugs in the the "array ('category','your_slug1', 'your_slug2')"

    //$cats = wp_get_post_categories($post->ID);
                            $cats = wp_get_object_terms($post->ID, array('category','events_categories','faq_category'), array('fields' => 'ids') );

    In file: wp-content/plugins/hikari-category-permalink/scategory_permalink.js
    Add the slugs again in the javascript file ....

    function onClick(event) {
          deselectAll();
    
          var current = $(this).prev('label').find('input').val();
    
          $('#in-popular-category-' + current + ',#in-category-' + current + ',#in-events_categories-' + current + ',#in-faq_category-' + current).each(function() {
            $(this).parent('label').css('fontWeight', 'bold');
            $(this).attr('checked', true);
          });
    
          $('#scategory_permalink').val(current);
          event.preventDefault();
        }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.