Site logo

[Resolved] Change the category pages using elements / hook

Home Forums Support [Resolved] Change the category pages using elements / hook

Home Forums Support Change the category pages using elements / hook

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2212202
    Anders Nielsen

    Hi

    I’m trying to make a blog category look like a “normal” page.

    – So I want to remove all blogpost from it.

    I have setup an element block – with my new design.

    I’m trying to hook in the new design to that specific category page, but I can’t find a hook – that inserts my content, and removes all the blogposts from the category view.

    Can you help me locate the right hook for this?

    I use generateblocks too.

    #2212207
    Anders Nielsen

    Ok, found the “Template part” where I can overwrite the page.

    But the category name (H1) is still there on the page – som hov do I remove it?

    #2212279
    David
    Staff
    Customer Support

    Hi there,

    you can unhook the archive title:

    add_action( 'after_setup_theme', function() {
        if ( some_condition_is_met() ) {
            remove_action( 'generate_archive_title', 'generate_archive_title' );
        }
    } );
    #2212330
    Anders Nielsen

    Hi David

    Thanks – but I got this error inserting the snippet in functions.php

    `Uncaught Error: Call to undefined function some_condition_is_met() in wp-content/themes/generatepress/functions.php:125
    Stack trace:
    #0 wp-includes/class-wp-hook.php(307): {closure}(”)
    #1 wp-includes/class-wp-hook.php(331): WP_Hook->apply_filters(NULL, Array)
    #2 wp-includes/plugin.php(474): WP_Hook->do_action(Array)
    #3 wp-settings.php(565): do_action(‘after_setup_the…’)
    #4 wp-config.php(97): require_once(‘/home/goteam/do…’)
    #5 wp-load.php(50): require_once(‘/home/goteam/do…’)
    #6 wp-admin/admin.php(34): require_once(‘/home/goteam/do…’)
    #7 wp-admin/theme-editor.php(10): require_once(‘/home/goteam/do…’)
    #8 {main}

    #2212349
    David
    Staff
    Customer Support

    Sorry i was meant to say – you need to replace: some_condition_is_met() with the condition you want to make the change to.

    eg.

    add_action( 'after_setup_theme', function() {
        if ( is_category() ) {
            remove_action( 'generate_archive_title', 'generate_archive_title' );
        }
    } );

    This will apply to only the Category archives ( not tags or other taxonomies ).

    If you want to apply it to a specific category you can include its slug: is_category('the-category-slug')

    Of this will remove it from all archives.

    add_action( 'after_setup_theme', function() {
        remove_action( 'generate_archive_title', 'generate_archive_title' );
    } );
    #2212352
    Anders Nielsen

    Awesome … Now I understand, thanks 🙂

    #2212361
    David
    Staff
    Customer Support

    Glad to hear that!

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