Dies ist eine Folge meines vorherigen Posts, jetzt mit anderem Code."Load More" -Link ausblenden, wenn keine weiteren Posts geladen werden sollen
Ich habe das funktioniert, es lädt den Inhalt ich will, alle Seiten (siehe previous post). Ich habe 9 Seiten (Standard-WP-Archiv, wo ich next_posts_link als "Anker" für den Klick verwenden.
Aber wenn Seite 9 geladen wird, klicke ich auf "Load More" und es lädt Seite 9 .... Ich will es zu stoppen und die „Last mehr“ Link zu verbergen. Jede Hilfe sehr geschätzt.
jQuery(document).ready(function($) {
var $content = '#upplevelser';
var $nav_wrap = '.navigation';
var $anchor = '.navigation .nav-previous a';
var $text = 'Load More';
var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts
$($nav_wrap).html('<a id="nav-below" href="' + $next_href + '">' + $text + '</a>');
$('#nav-below a').click(function(e) {
e.preventDefault();
if(jQuery(this).attr("href") == "") {
alert('I am empty href value');
}
$.get($(this).attr('href'), '', function(data) {
var $timestamp = new Date().getTime();
var $new_content = $($content, data).wrapInner('<div class="more-articles-here" id="rtz-' + $timestamp + '" />').html(); // Grab just the content
$next_href = $($anchor, data).attr('href'); // Get the new href
$($nav_wrap).before($new_content); // Append the new content
$('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load
$('#nav-below a').attr('href', $next_href); // Change the next URL
$('.more-articles-here ' + $nav_wrap).remove(); // Remove the original navigation
});
});
});