Forums

[resolved] Changing sidebar number for posts (5 posts)

  1. hostwings
    Member
    Posted 1 year ago #

    I'm currently using the Sparks theme by FThemes, which I've edited somewhat. It has a two sidebars layout, with the entry posts being in the middle.

    Was wondering if there is any way to get rid of one side bar when a user clicks on an entry. So for example, the left sidebar will stay and the entry area will widen and stretch to the right. I'm not too familiar with CSS and PHP, usually i search for the codes and modify an existing template that way.

    The ones I've found so far are for changing the content of a sidebar on different pages, but would like to actually delete one on all posts and pages except the home page. Would appreciate any instructions on how to carry it out. Thanks!

  2. JarretC
    Member
    Posted 1 year ago #

    You would have to modify the code in both page.php and single.php in your theme.

    If you wanted to remove the left sidebar you would remove the

    <?php get_template_part('content', 'before'); ?>

    piece of code in both single/page.php and if you wanted to remove the right sidebar you would remove

    <?php get_template_part('content', 'after'); ?>

    in both files.

    Of course you'll probably have to do some CSS editing to get things to display right afterwards.

  3. hostwings
    Member
    Posted 1 year ago #

    Thank you! Works beautifully with a little CSS tweak. Although I couldn't remove the left sidebar for some reasons, it just messes up the whole page. But just deleting the right sidebar works fine. Out of curiosity, any ideas why that's the case?

    The codes for single.php

    [Code moderated as per the Forum Rules. Please use the pastebin]

  4. hostwings
    Member
    Posted 1 year ago #

    I'm guessing actually it has to do with the content-before.php

  5. hostwings
    Member
    Posted 1 year ago #

    Ok. Figured it out by tweaking the content-before.php, index.php and header.php files.

    Once again, thanks for the tip. Really helped for me to figure out how the php works.

Topic Closed

This topic has been closed to new replies.

About this Topic