[Resolved] Primary navigation below featured image only on blog and archive pages

Home Forums Support Primary navigation below featured image only on blog and archive pages

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1343221
    Joey

    My blog page has a full page image added to it via elements page hero (https://simipress.com/home/). I used the following code to move the primary navigation below the image. It has the same effect on featured images of the blog, which are also full page photos via elements.

    add_action( 'after_setup_theme','craig_move_navigation' );
    function craig_move_navigation() {
        remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
        add_action( 'generate_after_header', 'generate_add_navigation_after_header', 15 );
    }

    The trouble is, the above code also moves the primary navigation below images in regular pages where there is a featured image, full page or not. How can I adjust the above code so that the navigation is only changed on the pages associated with blog posts? (Main blog page hero and all individual blog posts featured images) I’ve scourged the forums but can’t find this exact change. Thanks in advance.

    #1343371
    David
    Staff
    Customer Support

    Hi there,

    try this:

    add_action( 'wp','db_single_post_move_navigation' );
    function db_single_post_move_navigation() {
        if ( is_single() || is_home()  ) {
            remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
            add_action( 'generate_after_header', 'generate_add_navigation_after_header', 15 );
        }
    }  
    #1343992
    Joey

    Hi David,

    Your code works for single posts, which I need, but I need it to work as well for the main blog page.(https://simipress.com/home/)

    It is an issue because some of my pages donĀ“t have full screen images (as in this page https://simipress.com/submissions/) and it makes the heading look weird. Another way to handle it would be to lower the header on all full page images, whichever is easier. Thanks for responding so soon.

    #1344066
    Leo
    Staff
    Customer Support

    Try removing the conditional tag instead:

    add_action( 'wp','db_single_post_move_navigation' );
    function db_single_post_move_navigation() {
            remove_action( 'generate_after_header', 'generate_add_navigation_after_header', 5 );
            add_action( 'generate_after_header', 'generate_add_navigation_after_header', 15 );
    }  
    #1344104
    Joey

    Leo, it didn’t work. It has the same effect as my original code.

    Worse comes to worst I can not do featured images on pages, and figure out a way to put the first post image above the title. Other ideas?

    #1344349
    David
    Staff
    Customer Support

    I edited the code here – it now checks if it is a single post or the blog page.

    #1344878
    Joey

    That worked David, thank you both. I need to learn PHP so I can do this myself.

    #1345140
    David
    Staff
    Customer Support

    Glad we could be of help

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.