skip to Main Content

Is it possible to retrieve ALL links generated in a wordpress site?
I am talkin about pages, dynamic links generated on a user request, custom post type and so on
I tried a couple of plugin to get the map of a site but I only get a list of my static page. Instead, mappers online can go trough all my links and show me all the links.

Is there a way to have a list of them? may using php o wordpress codex?
I need to scrape them all to retrieve the last 3 link generated and show them in homepage

Need to show last 3 gallery added using NextGen gallery plugin, but the plugin show only link in this order:
domain.eu/slug/album/galleryname/gallery

2

Answers


  1. Chosen as BEST ANSWER

    I was thinking about matching all possible combination between album and galleries, since (in my site) the link of a gallery is given in this way: www.site.xx/album/album-name-slug/gallery-name-slug

    I was able to retrieve all galleries-name/album-name slugs from the database.

    Using php arrays, now I want to combine the last three galleries slugs added to database with all album slugs: since all galleries have different slugs, I want to perform a validation using php on the links generated, and if it matches, then I will have my link to the last 3 gelleries.


  2. No need to grab all the links on the website. You can use a WP_Query to grab the last 3 galleries like so

    <?php
    
    $gallery_query = new WP_Query([
        'post_type' =>  ['ngg_gallery'],
        'posts_per_page'    =>  3
    ]);
    
    while ( $gallery_query->have_posts() ) : $gallery_query->the_post();
    
        $link = get_the_permalink();
    
        // output your HTML using $link however you need to use it
    
    endwhile;
    

    If that doesn’t work for you, you could also hook into one of these post updated hooks where you could check if a page containing a NewGen gallery was updated, and if so store it in the database, probably in a WP Option where you keep track of the last three pages that contained NextGen galleries.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search