Show only the newest instagram picture with instafeed

630 Views Asked by At

So I need to show only one Instagram picture, which is the newest picture from the Instagram account. This HTML code shows all the pictures the account has.

<!DOCTYPE html>
<html>
<head>
    <title>Instagram</title>
    <style type="text/css">
        a img{ 
            width: 25%;
        }
    </style>
</head>
<body>
    <h1 style="text-align: center"></h1>
        <div id="instafeed-container"></div>



    <script src="https://cdn.jsdelivr.net/gh/stevenschobert/[email protected]/src/instafeed.min.js"></script>
    <script type="text/javascript">
    var userFeed = new Instafeed({
        
        get: 'user',
        target: "instafeed-container",
        resolution: 'low_resolution',
        accessToken: 'YOURACCESSTOKEN'
    });
    userFeed.run();
    </script>
</body>
</html>

So how do I filter the pictures and only show the newest picture? I tried to use "limit: '1", but it doesn't show anything at all.

2

There are 2 best solutions below

0
On BEST ANSWER

You can limit the number of records, as per the documentation e.g,

limit : 1

in Instafeed Object.

see here in the documentation

0
On

You only need the following styling

  ```  <!DOCTYPE html>
<html>
<head>
    <title>Instagram</title>
    <style type="text/css">
        #instafeed-container a{
        display:none}
    #instafeed-container a:nth-child(1){
    display:block}
        a img{ 
            width: 25%;
        }
    </style>
</head>
<body>
    <h1 style="text-align: center"></h1>
        <div id="instafeed-container"></div>



    <script src="https://cdn.jsdelivr.net/gh/stevenschobert/[email protected]/src/instafeed.min.js"></script>
    <script type="text/javascript">
    var userFeed = new Instafeed({
        
        get: 'user',
        target: "instafeed-container",
        resolution: 'low_resolution',
        accessToken: 'YOURACCESSTOKEN'
    });
    userFeed.run();
    </script>
</body>
</html>```