Anonymous
Как добавить URL-ссылку на изотоп
Сообщение
Anonymous » 25 окт 2024, 03:33
Я создаю веб-сайт с темой Wp и использую галерею изображений с изотопом, выбрав
http://jasonskinner.me/2013/04/creating ... o-gallery/ в качестве предпочтения. Теперь я хочу, чтобы мой изотопный фильтр можно было открыть по внешней ссылке, используя кошачью ссылку ex #art-concept. Я перепробовал все руководства, но моя URL-ссылка не изменилась. Может ли кто-нибудь мне помочь? Я все еще новичок в этом.
кстати, мой код:
Код: Выделить всё
//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
});
и у меня здесь есть собственное облако тегов, повлияет ли это на мою URL-ссылку?
Код: Выделить всё
//----------------------------------------------
//-------------------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 $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[] = "[url=#filter=$tag_name]$tag_name[/url]"; //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 = "[list]\n\t
[*][url=filter]All[/url]
[*]";
//join
$return .= join( "\n\t[*]", $a );
$return .= "\n[/list]\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 .
Спасибо заранее.
Подробнее здесь:
https://stackoverflow.com/questions/309 ... at-isotope
1729816425
Anonymous
Я создаю веб-сайт с темой Wp и использую галерею изображений с изотопом, выбрав http://jasonskinner.me/2013/04/creating-a-filterable-wordpress-photo-gallery/ в качестве предпочтения. Теперь я хочу, чтобы мой изотопный фильтр можно было открыть по внешней ссылке, используя кошачью ссылку ex #art-concept. Я перепробовал все руководства, но моя URL-ссылка не изменилась. Может ли кто-нибудь мне помочь? Я все еще новичок в этом. кстати, мой код: [code]//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 }); [/code] и у меня здесь есть собственное облако тегов, повлияет ли это на мою URL-ссылку? [code]//---------------------------------------------- //-------------------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 $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[] = "[url=#filter=$tag_name]$tag_name[/url]"; //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 = "[list]\n\t [*][url=filter]All[/url] [*]"; //join $return .= join( "\n\t[*]", $a ); $return .= "\n[/list]\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 ); } [/code] Мой веб-сайт www.uniqueconceptz.com. Спасибо заранее. Подробнее здесь: [url]https://stackoverflow.com/questions/30994085/how-to-add-url-link-at-isotope[/url]