Я пытаюсь удалить тег
из родной галереи WordPress через jquery и перепробовал множество способов, но ни один из них не работает ..
Я попробовал несколько кодов ниже (примечание: я изменил в файле темы
на
также я отменил регистрацию jquery и зарегистрировался в googleapis для своей темы.
<script>$('br.clearboth').html();</script>
и
<script>
(function($) {
$.strRemove = function(theTarget, theString) {
return $("<br/>").append(
$(theTarget, theString).remove().end()
).html();
};
})(jQuery);
</script>
Я размещаю этот код точно в верхней части элемента ввода wordpress. Может быть, я размещаю скрипт не в том месте , Ничего не работает, и ничего из этого не удаляет какой-либо тег br из раздела галереи...
Фактический исходный код, который я получаю, как показано ниже.ул. плохо там.
<!--BEGIN: Single Post-->
<article class="post-866 gallery type-gallery status-publish hentry mp_gallery" id="post-866">
<div class="entry">
<!--[this js i have added here]-->
<script>
$("br.clearboth").remove();
</script>
<style type='text/css'>
#gallery-1 {
margin: auto;
}
#gallery-1 .gallery-item {
float: left;
margin-top: 10px;
text-align: center;
width: 33%;
}
#gallery-1 img {
border: 2px solid #cfcfcf;
}
#gallery-1 .gallery-caption {
margin-left: 0;
}
</style>
<!-- see gallery_shortcode() in wp-includes/media.php -->
<ul id='gallery-1' class='gallery galleryid-866 gallery-columns-3 gallery-size-thumbnail clearfix'><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0432.jpg' title='DSC_0432'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0432-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Lorem ipsum dolor sit amet," title="DSC_0432" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Lorem ipsum dolor sit amet,
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0503.jpg' title='DSC_0503'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0503-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium" title="DSC_0503" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0516.jpg' title='DSC_0516'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0516-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0516" title="DSC_0516" /></a>
</p></li>
<br class="clearboth" />
<li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0657.jpg' title='DSC_0657'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0657-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Most beautiful face evern catched before" title="DSC_0657" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Most beautiful face evern catched before
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0658.jpg' title='DSC_0658'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0658-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Beauty queen on the earth and praising pain was born and But I must explain to you how all this" title="DSC_0658" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Beauty queen on the earth and praising pain was born and But I must explain to you how all this
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0676.jpg' title='DSC_0676'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0676-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Handsome Guy will Look after you :)" title="DSC_0676" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Handsome Guy will Look after you :)
</p></li>
<br class="clearboth" />
<li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0677.jpg' title='DSC_0677'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0677-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="Dashing Guy who is looking for a gal" title="DSC_0677" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
Dashing Guy who is looking for a gal
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0125.jpg' title='DSC_0125'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0125-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0125" title="DSC_0125" /></a>
</p></li><li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0416.jpg' title='DSC_0416'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0416-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin." title="DSC_0416" /></a>
</p>
<p class='wp-caption-text gallery-caption'>
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin.
</p></li>
<br class="clearboth" />
<li class='gallery-item'>
<p class='gallery-icon'>
<a href='http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0431.jpg' title='DSC_0431'><img width="190" height="110" src="http://localhost/mediatuts/wp-content/uploads/2012/03/DSC_0431-190x110.jpg" class="attachment-thumbnail colorbox-866" alt="DSC_0431" title="DSC_0431" /></a>
</p></li>
<br style='clear: both;' />
</ul>
</article>
<!--END: Single Post-->