Add content after get_header
I don’t see any hook available to do so. As you are using Child theming, it would be best for you to take a copy of the header.php in the child theme folder and edit it as per your need.
I don’t see any hook available to do so. As you are using Child theming, it would be best for you to take a copy of the header.php in the child theme folder and edit it as per your need.
I’d use a filter. You can remove this: if (function_exists(‘bf_new_defaults’)) { return bf_new_defaults( $default_settings ); } else { return $default_settings; } and replace it with something like this: return apply_filters(‘bf_filter’, $default_settings) The following is a truncated, proof of concept version of the code so you can see how $default_settings gets altered. add_filter( ‘bf_filter’, function($default_settings) { … Read more
You can add or remove hooks from inside other hooks if you get the timing right but I don’t understand why you are making this so complex. function set_title($title) { global $wp_query,$post,$address; $address = $wp_query->query_vars[‘address’]; if ($address) { return $address; } } add_filter(‘wp_title’, ‘set_title’); If you need the share the value, use a static variable: … Read more
Use PHP to limit the strings, just as in the example you mention. However, we can just build the terms list ourselves, so we don’t have to write any filter. We use “get_the_terms” instead, which returns an array of strings, that we can then output and shorten: <?php $max = 30; //define your max characters … Read more
You can use the_content filter to modify content before it’s output. function my_the_content_filter( $content ) { // maybe limit to archive or single cpt display? if( is_post_type_archive( ‘your-cpt’ ) || is_singular( ‘your-cpt’ ) ){ global $post; $meta = get_post_meta( $post->ID, ‘some-key’, true ); if( false === $meta ){ return $content . ‘some extra content’; } … Read more
You only create an instance of your class on admin requests, so your CPT doesn’t exist on front end requests. Instead of: if( is_admin() ) $cpt = new CPT(‘cpt_child’); create the instance on all requests: $cpt = new CPT(‘cpt_child’);
You can try the edit_form_after_title action: add_action( ‘edit_form_after_title’, function(){ echo ‘<hr/><div>My custom HTML</div><hr/>’; }); to add your custom HTML after the permalink: It will inject the HTML between div#titlediv and div#postdivrich: <div id=”post-body-content”> <div id=”titlediv”>…<!– /titlediv –> <hr><div>My custom HTML</div><hr> <div id=”postdivrich” class=”postarea edit-form-section”>…</div> … </div> Tip: when you have question like this, best thing … Read more
Maybe you can move all the logic to added_post_meta & ‘updated_postmeta’ hooks. add_action( ‘added_post_meta’, ‘update_carnews_adverts_aprent’, 10, 4 ); add_action( ‘updated_postmeta’, ‘update_carnews_adverts_aprent’, 10, 4 ); function( $meta_id, $object_id, $meta_key, $meta_value ) { if ( $meta_key !== ‘_wpcf_belongs_carnews_id’ || ! is_numeric($meta_value) ) return; $post = get_post( $object_id ); if ( $post instanceof WP_Post && $post->post_type == ‘carnews-adverts’ … Read more
When you call add_meta_box() you must provide a unique ID as the first parameter. Consider this case: add_meta_box( ‘foobox’, ‘Foo Title’, ‘foo_callback’ ); add_meta_box( ‘foobox’, ‘Bar Title’, ‘bar_callback’ ); You will just get the Bar Title metabox now, because it will overwrite the first one. What you need is a new ID for each box: … Read more
Unfortunately it’s still not really doable in a clean way. You can see the latest about this here in this trac ticket #16031 I just checked the source and the filter is still basically the same.