• Hello,

    Website:
    Blog

    I would like to see my old posts listed on website homepage with a button #old posts# like in my blog. There will be 10 posts on home page and for the previous posts I dont want to use the arrow but to click on # old posts # button. which is in Turkish Language Eski Yazilar in my blog.

    I will remove arrows:

    #nav-below {
    display: none;
    }
    How I will add old posts button in orange color?

    Thanks,
    Selin.

Viewing 10 replies - 16 through 25 (of 25 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    I have copied from actual spun theme

    Did you only recently do this?

    Thread Starter Selinvarol

    (@selinvarol)

    yes just now.

    Thread Starter Selinvarol

    (@selinvarol)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Remove all code from your Child Theme functions.php file – otherwise your website will likely break if not now but in the future.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Only put this in it for now:

    <?php
    
    // Your customisations go here
    
    ?>

    Thread Starter Selinvarol

    (@selinvarol)

    ok.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Okay now outside of code, go to your website’s files and folders.

    You need to create a folder in your Child Theme called “js”. So, your Child Theme directory structure would be this:

    /wp-content/themes/spunv2/js/

    And then within that “js” folder create a file named “hide-old-posts.js” – importantly with the “.js” extension. So, your Child Theme directory structure with the new file would be this:

    /wp-content/themes/spunv2/js/hide-old-posts.js

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Then open your “hide-old-posts.js” file and put this code into it:

    $=jQuery;
    
    // Get the non-stiky posts
    var nonStickyPosts = $('.blog .hentry:not(.sticky)');
    
    // Hide all posts that aren't stickies
    nonStickyPosts.hide();
    
    // Add your button that'll toggle the old posts
    $('#content').append('<a href="#" id="toggle-old-posts">Old posts</a>');
    
    // When that toggle button has been clicked on
    $('#toggle-old-posts').click(function(){
    
      //Toggle the non-sticky posts
      nonStickyPosts.toggle();
    
    });

    [Note that this doesn’t style the toggle button – we can do that with CSS later]

    Thread Starter Selinvarol

    (@selinvarol)

    I did all.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Now in your Child Theme functions.php add a function that’ll load this “hide-old-posts.js” file:

    <?php
    
     // Your customisations go here
     function hideOldPosts() {
            wp_enqueue_script( 'hide-old-posts', get_stylesheet_directory_uri() . '/js/hide-old-posts.js', '', '1.0', true );
     }
    
     add_action( 'wp_enqueue_scripts', 'hideOldPosts' );
    
    ?>

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘How to list old posts on home page without an arrow’ is closed to new replies.