[Support request] hook page-header with wordpress hooks

Home Forums Support [Support request] hook page-header with wordpress hooks

Home Forums Support hook page-header with wordpress hooks

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #235176


    I want to manage multiple pages (about 200 hundred) with gp and the page-header add-on is able to give me the layout i wan’t. But unfortunatly, i haven’t found the way to have a default page header in this way.

    So, what i have done:
    I have hooked with ‘get_post_metadata’ wp filter and i can make it works the way i want, using conditional tags to apply global changes to page-header settings when needed.

    add_filter( 'get_post_metadata', 'al_gp_get_post_metadata', 100, 4 );
    function al_gp_get_post_metadata($metadata, $object_id, $meta_key, $single){
        // Here is the catch, add additional controls if needed (post_type, etc)
        $meta_needed = '_meta-generate-page-header-content';
        if ( isset( $meta_key ) && $meta_needed == $meta_key ){
    	    remove_filter( 'get_post_metadata', 'al_gp_get_post_metadata', 100 );
    	    $current_meta = get_post_meta( $object_id, $meta_needed, TRUE );
    	    add_filter('get_post_metadata', 'al_gp_get_post_metadata', 100, 4);
    	    if (!$current_meta) return '<h2>test</h2>';
    	    else return $metadata;

    But there is two problems with doing this like that:
    1 – The most important one: can I be sure that you won’t change the metakeys in the future (can you officially support this way of modify page-header settings) ?
    2 – For some parameters like ‘_meta-generate-page-header-image-background’, only two settings can be checked ‘yes’ or ” > so i can’t know if current post page-header settings have chosen ‘no’ or have chosen nothing.
    3 – I am not surer it is cpu effective.

    If you can’t offically support my way of doing:
    > Is there another solution i don’t know ?
    > If not, i suggest a simple filter hook (not only for page-header settings but for every feature with no way to make global settings) > Example:

    add_filter( 'gp-page-header-settings', function((array) $gp_page-header-settings, $post,...) {
    // modify $gp_page-header-settings
    return $gp_page-header-settings;
    Lead Developer
    Lead Developer

    Hi there,

    That’s an interesting way of doing it.

    The meta keys shouldn’t change, although I can’t guarantee that. It would be mentioned in the changelog if they did, but I don’t see that happening any time soon.

    Personally, I would just build the page header in GP Hooks so it applied to all pages.

    The best way to do that would be to build it on a page using the settings you want, then copy the HTML generated and the CSS generated.

    Then add that HTML into GP Hooks, and add the CSS to your child theme or CSS plugin.

    Let me know if that makes sense or not 🙂

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