• Resolved callaloo

    (@callaloo)


    1. The post and page have something like body:not(single-post):not(.page). How about error404 page? I was styling the blog and archives pages and it is affecting error404 page, making me write custom CSS for .error404 to correct it.
    2. How do I assign this as widget title to a shortcode hooked after the right sidebar content? <div class="widget-title">Widget Title</div> Here is the function

    add_action( 'generate_after_right_sidebar_content', 'gp_side_comments_box');
    function gp_side_comments_box() {
        if (! is_single() || (! is_page) ) {
            echo do_shortcode( '[comments-widget]' );
       }
    }
Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter callaloo

    (@callaloo)

    Also, using this code does not work to hide content on posts and pages. It only works when one of them is used, that is, ! is_single() or ! is_page.

    add_action( 'generate_after_right_sidebar_content', 'gp_side_comments_box');
    function gp_side_comments_box() {
        if (! is_single() || (! is_page) ) {
            echo do_shortcode( '[comments-widget]' );
       }
    }
    Theme Author Tom

    (@edge22)

    Hi there,

    1. The 404 page has this class you can target: error404

    You might be able to do this:

    body:not(single-post):not(.page):not(.error404)

    2. Would this work?:

    add_action( 'generate_after_right_sidebar_content', 'gp_side_comments_box');
    function gp_side_comments_box() {
        if (! is_single() || (! is_page) ) {
            echo '<div class="widget-title">Widget Title</div>';
            echo do_shortcode( '[comments-widget]' );
       }
    }

    3. When exactly are you wanting the widgets to display? On archives only? If so, try is_archive()

    Thread Starter callaloo

    (@callaloo)

    1. Thanks. It worked.
    3. On the homepage and archive pages but avoid single post, page and error page. I found using ! is_singular() works too, but not on the error page. If you have a better solution, I wouldn’t mind.

    Theme Author Tom

    (@edge22)

    Try this:

    if ( is_archive() || is_front_page() ) {
    
    }
    Thread Starter callaloo

    (@callaloo)

    It worked too. Thanks.

    Theme Author Tom

    (@edge22)

    You’re welcome 🙂

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Two topics’ is closed to new replies.