0

I am in quite a trouble. I need to extract all possible url from my wordpress blog be it of post, tag, category or anything else after domian-name.tld/*. I tried my hand on few available codes and plugins but none worked for me. This code works fine but extracts only post URL's i need rest too. I will be really thankful, if somebody could help me out on it.

<?php

include "wp-load.php";

$posts = new WP_Query('post_type=any&posts_per_page=-1&post_status=publish');
$posts = $posts->posts;
/*
global $wpdb;
$posts = $wpdb->get_results("
    SELECT ID,post_type,post_title
    FROM {$wpdb->posts}
    WHERE post_status<>'auto-draft' AND post_type NOT IN ('revision','nav_menu_item')
");
*/

header('Content-type:text/plain');
foreach($posts as $post) {
    switch ($post->post_type) {
        case 'revision':
        case 'nav_menu_item':
            break;
        case 'page':
            $permalink = get_page_link($post->ID);
            break;
        case 'post':
            $permalink = get_permalink($post->ID);
            break;
        case 'attachment':
            $permalink = get_attachment_link($post->ID);
            break;
        default:
            $permalink = get_post_permalink($post->ID);
            break;
    }
    echo "\n{$post->post_type}\t{$permalink}\t{$post->post_title}";
}
  • You can retrieve a term link by using get_term_link after fetching terms through get_terms. That should get you started. – engelen Jun 18 '14 at 6:52
  • hello Engelen, i have no idea what you are asking me to do. im a novoice in coding. kindly explain me in detail what i need to do. – lucas Jun 18 '14 at 7:28
  • Can you explain what you are trying to do by extracting all the links? – sri Jun 18 '14 at 7:58
  • there is a malicious code in my setup, i don't know which file hosts it, coz all available scanning methods shows site is clear. Whereas few days ago i noticed banner ads in header and footer section of blog. When i hit opened them there were no such script there but banner ads continue to appear on pages. So i am planning to resetup whole site, for that i need to know all the urls so that i can use same taxonomies urls and loose no seo. – lucas Jun 18 '14 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.