Jump to content

shir

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by shir

  1. I'm pretty sure there's an easy solutions for that, but I can't find it

    I want the latest 10 posts to display in my Homepage, and the posts before them to not display at all in the homepage (they'd display only if someone is searching them, or find them under tags, etc...). Meaning, I don't want to be pages 2,3,4, etc. to the homepage.

    I've tried 3 things, but none make the pagination disappear:

    1) Adding the following code into style.css (in child theme files):

    .category .entry-pagination {
    display: none;
    }
    .home .entry-pagination {
    display: none;
    }

    2) Adding the following code into additional CSS:

    p.post-nav-links { display: none; }

     

    3) Duplicating index.php file into child theme, and there deleted the following code piece (actually, this one ended with an error, so I might deleted too much/too little code piece?)

    <?php the_posts_pagination( array(
    'prev_text' => __( 'Previous', 'newscard' ),
    'next_text' => __( 'Next', 'newscard' ),
    )
    );
    else :
    get_template_part( 'template-parts/content', 'none' );
    endif;
    ?>

    homepage pagination.PNG

  2. It's indeed determined by the time the post was published (=latest posts).
    However, I'm looking for the code who'd say; let's publish the latest 5 posts in the 3 sections - while each one would appear once.
    Meaning, avoid post duplicated display
    , as well as determine the post order, as I mentioned above (latest under "main story", the 2 before - under "trending stories", the 2 before - under "editor's pick".

    I got one code to prevent duplication. But it made the posts display disappeared from the top 3 sections completely, and leave display of latest post only in the sections below the 3 top sections.

    The code was (if that helps): + attached screenshot after implanting the code
     

    add_action('parse_query', 'mts_exclude_duplicates');

    function mts_exclude_duplicates( &$query ) {

    if (!is_home()) return;

    global $adp_posts;

    $disable_now = $query->get('adp_disable'); // use 'adp_disable' to prevent exclusion

    if (empty($query->post__not_in) && empty($disable_now)) {

    $query->set('post__not_in', $adp_posts);

    }

    }

     

    add_filter('the_posts', 'mts_log_posts', 10, 2);

    $adp_posts = array();

    function mts_log_posts( $posts, $query ) {

    if (!is_home()) return $posts;

    global $adp_posts;

    foreach ($posts as $i => $post) {

    $adp_posts[] = $post->ID;

    }

    return $posts;

    }

    hp after implanting code.PNG

  3. I have 3 sections In my WP theme in the display of the homepage:
    "main story", "editor's pick" and "trending stories".
    Each one of my latest 2 posts displayed several times in the homepage in different sections (!): under "main story", under "editor's pick" and under "trending stories".

    Instead, I want all the 5 latest posts will display on the homepage, but each of them will appear once only.
    (For example: under main story - post 1, under trending - posts 2+3, under editor's pick - posts 4+5).

    How can I do this?

    Attached screenshot of my homepage

    newscard homepage.PNG

×
×
  • Create New...