Please bear with me here because I am a total beginner when it comes to JSON and AJAX and abstracting jQuery.

So far I have gotten to a point where I can loop through an array that contains the IDs of all of my first level links, and fetch the data from my JSON file that corresponds with that same index.

OK! So:

JSON file can be seen here:

Demo website can be viewed here:


var slugArray = [
function getWWD(){
  $.getJSON('../linking-to-another-index-in-json-file/wp-content/themes/bmgz/data/whatwedo.js', function(result){
    $.each(slugArray, function(i, selection){
        $("#w-dropdown header img").attr('src', result[i].icon);
        $("#w-dropdown h4").html(result[i].name);
        $("#w-copy header").html(result[i].name);
        $(result[i].cousins).each(function(index, item){
        $("#w-copy p").html(result[i].copy);
        $("#wwd-sub-icons img:first-child").attr('src', result[i].subicon1);
        $("#wwd-sub-icons img:last-child").attr('src', result[i].subicon2);

What I’d like to do is the following:

In the subpages that get generated by the getWDD(); function:

  • To check the img src of the $(“#wwd-sub-icons img:first-child”) and $(“#wwd-sub-icons img:last-child”) and, depending on the src, force the index to be 1, 4, or 7 and have all subpage content jump to the JSON values for the object at that index.

  • To have the generated list items with class “wwd-li” exhibit the following behavior when clicked: Grab the text that’s inside the list item and use this to find the index inside the JSON file where the result[i].name is the same as the text in the li, then adjust the index of all of the other on-page data to match that new index.

Any and all guidance or tutorials would be appreciated!!!! Thank you!!

Read more here: Linking to another index in JSON file


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , ,

Wordpress related questions and answers: