Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8151435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:23:19+00:00 2026-06-06T15:23:19+00:00

I have a main loop that I replace with other loops when certain icons

  • 0

I have a main loop that I replace with other loops when certain icons are clicked. Each loop actually has it’s own page but for users using javascript I simply allow them to switch loops in the homepage content area. I read a tutorial on how to do it and it uses # as the href for links which doesn’t allow me to link to the actual page and just have javascript ignore that link and do the ajax instead. So my question is how can I set this process below up so it degrades gracefully.

I have a page called mysite.com/my-favorites.

This is how I call that pages content with ajax on my homepage.

<a id="fav" class="trigger-loop" href="#"><div id="favorite-icon"></div></a>

jQuery(document).ready(function($){
 $('#fav.trigger-loop').click(function(){
    $('.trigger').removeClass('active');
    $('.trigger-loop').removeClass('active');
    $('#fav.trigger-loop').addClass('active');
    $('#boxes').empty();
    $.post(
        WPaAjax.ajaxurl,
        {
            action : 'loop_fav',
        },
        function( response ) {
            $('#boxes').append( response ).masonry( 'reload' );
            $('.panel').hide("slow");
        }
    );
 });

});

add_action('wp_ajax_loop_fav', 'loop_fav');
function loop_fav(){
 wpfp_shortcode_func();

 exit;
}    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:23:21+00:00Added an answer on June 6, 2026 at 3:23 pm

    If I’ve got your question right.

    Add the url instead of #,

    <a id="fav" class="trigger-loop" href="mysite.com/my-favorites"><div id="favorite-icon"></div></a>
    

    and in your click function, return false; so your page does not jump to the specified url and do an ajax instead.

     $('#fav.trigger-loop').click(function(){
         ... your code...
         ... your code....
         return false; 
    
     })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing program that has its own main loop, and does computations
I have main table called 'Employee' and another slave table called 'EmployeeTypes' that has
I have a script with a main for loop that repeats about 15k times.
If you have worked with gui toolkits, you know that there is a event-loop/main-loop
On Linux under X11 and using GTK+ you have something called Main Loop. Once
I have already cut everything I could from the main loop. I also optimized
I have a main form ( form1 ). Within that form I successfully open
I have made some research on Stackoverflow about reverse for loops in C++ that
I have an activity(say, MyActivity) that contains fragments, and i am using fragmentTransaction.replace(XX,YY) for
I have one 'main' thread that creates an array of objects of class SlowData

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.