Add class to all meta boxes for a custom post type

After doing some playing around, I discovered this can actually be accomplished by defining the name of the hook I want to add the filter to via a variable. So if my $post_type_name is portfolio and my $box_id is piece_info, I can make a filter as follows: function add_meta_box_class( $classes ) { array_push( $classes, ‘custom-class’); … Read more

How to trigger click events using hooks

That’s not possible (well, not without building super weird things). Action hooks are server side in PHP, clicks happen on the client side. You should probably use JavaScript to run the actions when the form is submitted. With jQuery, this could be as easy as jQuery(“#formid”).submit( function() { jQuery(“#someButton”).click(); }); Depending on what else you … Read more

Get First Post content and edit it using pre_get_posts (or similar?!)

You can use the loop_start hook which passes the $WP_Query object by reference. namespace StackExchange\WordPress; class editFirstPostContent { public function load() { if( \is_admin() ) { return; } \add_filter( ‘loop_start’, [ $this, ‘loopStart’ ] ); } public function loopStart( \WP_Query $WP_Query) { if( ! $WP_Query->is_main_query() ) { return; } if( ! isset( $WP_Query->posts[0] ) ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)