• Hello,
    I didn’t know really in which forum to post, so decided in this one.
    I am making a multisite with Category Sticky Plugin, the theme is Macchiato (child theme, of course).
    Most of the Menu choices are categories, not pages.
    On most of these I have one sticky post which is the basic info I want to see, and I added a line to content.php and the content-archive.php files asking to see any sticky post in full content (not as excerpt).
    The home page needs to only show one single category, so I have added a line to the functions.php file.
    However, – all the sticky posts still show on the home page.
    I am not a coder, the code I found while searching for an answer on the Internet. The theme people do not help.

    What I need and don’t know how to do is change the code added so that even if post is sticky, it will still show only the one category.

    This is the code added to content.php file:

    <?php if ( is_sticky() ) {
    			the_content();
    		}
    	 else {?>
    
        <div class="post_excerpt">
            <?php the_excerpt(); ?>
        </div>
        <div id="read-more">
            <a href="<?php the_permalink('') ?>" ><?php _e( 'המשך קריאה...', 'wp-macchiato' ); ?></a>
        </div>
    <? } ?>

    This is the code put in content-archive.php:

    <div class="post_excerpt">
    		                <?php if ( is_sticky() )
    					the_content();
    				else
    					the_excerpt();
    				?>
    		            </div>

    This is the function I found on the internet to only display one category on home page:

    function my_home_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '1'); } } add_action( 'pre_get_posts', 'my_home_category' );

    Please help me make the change.
    Thank you very much in advance and Happy New Year,
    Vera

  • The topic ‘Sticky posts on home page’ is closed to new replies.