[resolved] Getting to only show on homepage (4 posts)

  1. focusfilm
    Posted 3 years ago #

    So I'm after getting this featured posts widget to only show up on the homepage, as at the moment it causes all kind of bother after page 2 of recent posts. I've tried fixing it myself but it breaks the entire homepage.

    Below is the current function, if you could please tell me how I should edit this to do what I want it to.

    <?php if ( $paged < 4 && option::get('feat_show') == 'on' ) get_template_part('wpzoom', 'featured'); ?>

    Any help would be greatly, greatly appreciated as I'm on a time limit. Thanks guys!

  2. Michael
    Forum Moderator
    Posted 3 years ago #

  3. focusfilm
    Posted 3 years ago #

    Sorry I'm rubbish with the wordpress explanations. I can never understand what they're getting at. If anyone can please just edit that piece of code I've provided to do what I want I'd be very grateful. Thanks anyway alchymyth!

  4. focusfilm
    Posted 3 years ago #

    Never mind, just figured it out.

    For anyone else having the same problem, it was a case of creating a new .php file then pasting in that piece of code you only want on the homepage then calling that page template in the index.php file by:

    <?php get_template_part('NAME OF TEMPLATE PAGE'); ?>

    wrapped so it looked like this:

    if (is_home() && strpos($_SERVER['REQUEST_URI'], "/page/") === false) {
    ?><?php get_template_part('NAME OF TEMPLATE PAGE'); ?><?

    Now it only calls on that template on the home/index page. Hope this is helpful to people having the same problems in the future!

Topic Closed

This topic has been closed to new replies.

About this Topic