• Hello
    I’m looking for 2 plugins.
    1) A plugin which add 10 links (a good option if number can be configured as well) to other pages on every page (sort of ‘related’ but not really as I don’t have any categories or tags for my pages)
    2) A plugin which display every pages on a page in 3 columns (or configurable) using shortcut.
    Any ideas? Thanks in advance!

    • This topic was modified 6 years, 4 months ago by Shwepps.
    • This topic was modified 6 years, 4 months ago by Jan Dembowski.
Viewing 5 replies - 1 through 5 (of 5 total)
  • For the first issue, adding 10 links to every page of your WordPress site, what are the business rules around what you’re looking to achieve? You mentioned this list of posts would not be “related” posts, so are they random? Do they need to be the same on every page?

    Do you truly just want 10 random links to posts to display?

    Try adding this to your functions.php file:

    function cleancoded_random_posts() { 
     
    $args = array(
        'post_type' => 'post',
        'orderby'   => 'rand',
        'posts_per_page' => 10, 
        );
     
    $the_query = new WP_Query( $args );
     
    if ( $the_query->have_posts() ) {
     
    $string .= '<ul>';
        while ( $the_query->have_posts() ) {
            $the_query->the_post();
            $string .= '<li><a href="'. get_permalink() .'">'. get_the_title() .'</a></li>';
        }
        $string .= '</ul>';
        /* Restore original Post Data */
        wp_reset_postdata();
    } else {
     
    $string .= 'no posts found';
    }
     
    return $string; 
    } 
     
    add_shortcode('cleancoded-random-posts','cleancoded_random_posts');
    add_filter('widget_text', 'do_shortcode'); 

    What this is, and how it works:

    This code creates a function that displays 10 random posts. It then creates a shortcode you can use to display random posts anywhere on your site (it also enables shortcodes to be executed inside WordPress widgets so that you can use this shortcode inside a text widget).

    Now you can display random posts inside a WordPress post, page or text widget using the shortcode [cleancoded-random-posts].

    And here’s a quick video walkthrough I created to show how to use this. I created a sandbox test install of WordPress, created and published some placeholder posts, added this code to my functions.php file, then added this shortcode to a widget, and show how the posts are displayed, in random order, in the sidebar:

    If this is too basic, or you need more functionality, have a look at this plugin, it creates a widget, and shortcodes that are configurable with a variety of parameters to suit your needs:

    https://www.ads-software.com/plugins/advanced-random-posts-widget/

    For number 2, it sounds like you’re looking for an HTML sitemap plugin. There are many of these to choose from, like this one:

    https://www.ads-software.com/plugins/simple-sitemap/

    Thread Starter Shwepps

    (@shwepps)

    Hi!
    Thanks for your input, but I need links to pages, not posts ?? Or should I just change ‘post/posts’ to ‘page/pages’ in the code above and it’s gonna work?

    For the first issue, adding 10 links to every page of your WordPress site, what are the business rules around what you’re looking to achieve?

    For SEO.

    Do you truly just want 10 random links to posts to display?

    Yep.

    For number 2, it sounds like you’re looking for an HTML sitemap plugin. There are many of these to choose from, like this one:

    Well, I need 3 or more columns otherwise it’s gonna be too long.

    Thread Starter Shwepps

    (@shwepps)

    Ok, first issue is still active.

    Do you mean about your request for help setting up an HTML sitemap with columns?

    Here’s an (admittedly older) plugin that might work for your WordPress site:

    https://www.ads-software.com/plugins/wp-seo-html-sitemap/

    I’ve just tested it with WordPress 4.9.8 and it seems to provide the functionality you’re looking for, please have a look here:

    Thread Starter Shwepps

    (@shwepps)

    No, no, about

    plugin which add 10 links (a good option if number can be configured as well) to other pages on every page (sort of ‘related’ but not really as I don’t have any categories or tags for my pages)

    There are a lot of pages on site and I want them to be linked to each other.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Links plugin’ is closed to new replies.