如何在同位素上添加Url链接

时间:2015-06-23 04:53:16

标签: jquery wordpress

我正在使用Wp主题创建网站,我正在创建使用带有http://jasonskinner.me/2013/04/creating-a-filterable-wordpress-photo-gallery/同位素的图库作为我的偏好。现在我想通过使用cat link ex#art-concept使用外部链接打开我的同位素过滤器。我已经尝试了所有指南但仍然我的网址链接没有改变。谁能帮助我?我还是新手。

顺便说一下我的代码:

//put jQuery in noConflict mode
var $j = jQuery.noConflict();

$j(document).ready(function() {
    //----------------------------------------------
    //--------------------------------------fancybox
    //----------------------------------------------

    //simple fancybox start
    $j('.fancybox').fancybox({
        //make sure fancybox knows we are loading images from wordpress
        'type': 'image',
        'autoSize' : true,
        //lock the background when fancybox is active so weird padding doesn't show up
        helpers : {
        overlay : {
            locked : false
        }
    }
    });

    //----------------------------------------------
    //---------------------------------------isotope
    //----------------------------------------------
    //set container variable so we don't have to type alot
    var $container = $j('.photogal');
    //run function when all images touched by isotope are loaded
    $container.imagesLoaded( function(){
        //set parameters
        $container.isotope({
            //tell isotope what to target
            itemSelector : '.element',
            //set the layout mode
            layoutMode: 'fitRows',
            //tell isotope to use CSS3 if it can and fallback to jQuery
            animationEngine : 'best-available',
            //set masonry parameter
            masonry: {
                //we want 5 columns
                columnWidth: $container.width() / 5
            }

        });
    });
    //tell isotope our filters are in the options id & links
    var $optionSets = $j('#options'),
    $optionLinks = $optionSets.find('a');

    //click function to sort by data
    $optionLinks.click(function(){
        var $this = $j(this);
        // don't proceed if already selected
        if ( $this.hasClass('selected') ) {
            return false;
        }
        var $optionSet = $this.parents('.option-set');
        $optionSet.find('.selected').removeClass('selected');
        $this.addClass('selected');

        // make option object dynamically, i.e. { filter: '.my-filter-class' }
        var options = {},
        key = $optionSet.attr('data-option-key'),
        value = $this.attr('data-option-value');
        // parse 'false' as false boolean
        value = value === 'false' ? false : value;
        options[ key ] = value;
        if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
            // changes in layout modes need extra logic
            changeLayoutMode( $this, options );
        } else {
            // otherwise, apply new options
            $container.isotope( options );
        }
    return false;
  });
});


$(function(){

  var $container = $('#filter'),
      $body = $('body'),
      colW = 60,
      columns = null;

  $container.isotope({
    // disable window resizing
    resizable: false,
    masonry: {
      columnWidth: colW
    }
  });

  $(window).smartresize(function(){
    // check if columns has changed
    var currentColumns = Math.floor( ( $body.width() -10 ) / colW );
    if ( currentColumns !== columns ) {
      // set new column count
      columns = currentColumns;
      // apply width to container manually, then trigger relayout
      $container.width( columns * colW )
        .isotope('reLayout');
    }

  }).smartresize(); // trigger resize to set container width

});

我在这里有自定义标签云,是否会影响我的网址链接?

//----------------------------------------------

//-------------------custom tag cloud generation

//----------------------------------------------



function jss_generate_tag_cloud( $tags, $args = '' ) {

    global $wp_rewrite;



    //don't touch these defaults or the sky will fall

    $defaults = array( 

        'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 0,

        'format' => 'flat', 'separator' => "\n", 'orderby' => 'name', 'order' => 'ASC',

        'topic_count_text_callback' => 'default_topic_count_text',

        'topic_count_scale_callback' => 'default_topic_count_scale', 'filter' => 1

    );



    //determine if the variable is null

    if ( !isset( $args['topic_count_text_callback'] ) && isset( $args['single_text'] ) && isset( $args['multiple_text'] ) ) {

        //var_export 

        $body = 'return sprintf (

            _n(' . var_export($args['single_text'], true) . ', ' . var_export($args['multiple_text'], true) . ', $count), number_format_i18n( $count ));';

        //create_function

        $args['topic_count_text_callback'] = create_function('$count', $body);

    }



    //parse arguments from above

    $args = wp_parse_args( $args, $defaults );



    //extract

    extract( $args );



    //check to see if they are empty and stop

    if ( empty( $tags ) )

        return;



    //apply the sort filter    

    $tags_sorted = apply_filters( 'tag_cloud_sort', $tags, $args );



    //check to see if the tags have been pre-sorted

    if ( $tags_sorted != $tags  ) { // the tags have been sorted by a plugin

        $tags = $tags_sorted;

        unset($tags_sorted);

    } else {

        if ( 'RAND' == $order ) {

            shuffle($tags);

        } else {

            // SQL cannot save you

            if ( 'name' == $orderby )

                uasort( $tags, create_function('$a, $b', 'return strnatcasecmp($a->name, $b->name);') );

            else

                uasort( $tags, create_function('$a, $b', 'return ($a->count > $b->count);') );



            if ( 'DESC' == $order )

                $tags = array_reverse( $tags, true );

        }

    }

    //check number and slice array

    if ( $number > 0 )

        $tags = array_slice($tags, 0, $number);



    //set array

    $counts = array();



    //set array for alt tag

    $real_counts = array();



    foreach ( (array) $tags as $key => $tag ) {

        $real_counts[ $key ] = $tag->count;

        $counts[ $key ] = $topic_count_scale_callback($tag->count);

    }



    //determine min coutn

    $min_count = min( $counts );



    //default wordpress sizing

    $spread = max( $counts ) - $min_count;

    if ( $spread <= 0 )

        $spread = 1;

    $font_spread = $largest - $smallest;

    if ( $font_spread < 0 )

        $font_spread = 1;

    $font_step = $font_spread / $spread;



    $a = array();



    //iterate thought the array

    foreach ( $tags as $key => $tag ) {

        $count = $counts[ $key ];

        $real_count = $real_counts[ $key ];

        $tag_link = '#' != $tag->link ? esc_url( $tag->link ) : '#';

        $tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;

        $tag_name = $tags[ $key ]->name;



        //If you want to do some custom stuff, do it here like we did

        //call_user_func

        $a[] = "<a href='#filter=$tag_name' class='tag-link-$tag_id' 

        data-option-value='.$tag_name' 

        title='" . esc_attr( call_user_func( $topic_count_text_callback, $real_count ) ) . "'>$tag_name</a>"; //background-color is added for validation purposes.

    }



    //set new format

    switch ( $format ) :

    case 'array' :

        $return =& $a;

        break;

    case 'list' :

        //create our own setup of how it will display and add all

        $return = "<ul id='filters' class='option-set' data-option-key='filter'>\n\t

        <li><a href='filter' data-option-value='*' class='selected'>All</a></li>

        <li>";

        //join

        $return .= join( "</li>\n\t<li>", $a );

        $return .= "</li>\n</ul>\n";

        break;

    default :

        //return

        $return = join( $separator, $a );

        break;

    endswitch; 

        //create new filter hook so we can do this

        return apply_filters( 'jss_generate_tag_cloud', $return, $tags, $args );

}

我的网站是www.uniqueconceptz.com。 谢谢。

0 个答案:

没有答案