• Resolved juchheim

    (@juchheim)


    How do I add where and orderby to:

    function fetchPodData(page) {
    
    $('#loadingMessage').show();
    
    $.ajax({
    
    url: '/wp-json/pods/teacher',
    
    type: 'GET',
    
    dataType: 'json',
    
    data: {
    
    page: page,
    
    per_page: 100
    
    },
    
    success: function(data, textStatus, jqXHR) {
    
    var totalPages = parseInt(jqXHR.getResponseHeader('X-WP-TotalPages'));
    
    podData = podData.concat(data);
    
    currentPage++;
    
    if (currentPage <= totalPages) {
    
    fetchPodData(currentPage);
    
    } else {
    
    displayPodData(podData);
    
    $('#loadingMessage').hide();
    
    }
    
    },
    
    error: function(jqXHR, textStatus, errorThrown) {
    
    $('#loadingMessage').hide(); // Hide loading message in case of error
    
    $('.threeColumn').html('<p>Error fetching Pod data.</p>');
    
    }
    
    });
    
    }

Viewing 1 replies (of 1 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @juchheim

    /wp-json/pods/teacher is not an endpoint to fetch post data, it’s for the information about that particular Pod. To fetch posts you’ll need to use the WordPress core REST API.

    The REST API is a WordPress core option, Pods optionally adds it’s fields to the results but cannot change in inner workings. Please refer to the WordPress core documentation.

    Cheers, Jory

Viewing 1 replies (of 1 total)
  • The topic ‘Where and orderby using AJAX, Rest API’ is closed to new replies.