How to change title attribute returned by comments_popup_link()?

If you look into the function comments_popup_link() you will see the following code at the end: $title = the_title_attribute( array(‘echo’ => 0 ) ); echo apply_filters( ‘comments_popup_link_attributes’, ” ); echo ‘ title=”‘ . esc_attr( sprintf( __(‘Comment on %s’), $title ) ) . ‘”>’; comments_number( $zero, $one, $more ); echo ‘</a>’; // last line Note the … Read more

How do I grab specific posts (by post id) and display the title, featured image, and excerpt?

I have not tested this but based on your question, this should get you on track: <?php $id = 4; // The Page or post ID $page_data = get_post( $id ); $title = $page_data->post_title; $content = $page_data->post_content; $excerpt = substr($content, 0, 155); $featured_image = wp_get_attachment_url( get_post_thumbnail_id($id, ‘thumbnail’) ); ?> <div class=”post”> <h1><?php echo $title; ?></h1> … Read more

Add my own function to existing WooCommerce hook

storefront_single_post hook pertains only to single posts and not products although products are considered posts of type ‘product’ This is the hook you need: add_action( ‘woocommerce_single_product_summary’, ‘storefront_post_header_categories’, 6 ); function storefront_post_header_categories() { echo “code to display categories here”; } You will find it in plugins/woocommerce/content-single-product.php: /** * woocommerce_single_product_summary hook * * @hooked woocommerce_template_single_title – 5 … Read more

Gutenberg gallery hook errors

Seems that when you modify the existing block’s HTML, then it is no longer being validated. Instead, you might try to create your own block. Look here is a good approach and here too.

Override wp_delete_post and move to trash instead for custom post type

Inside wp_delete_post() there is the following code, /** * Filters whether a post deletion should take place. * * @since 4.4.0 * * @param bool|null $delete Whether to go forward with deletion. * @param WP_Post $post Post object. * @param bool $force_delete Whether to bypass the trash. */ $check = apply_filters( ‘pre_delete_post’, null, $post, $force_delete … Read more

Run add_action hook if condition

I’d guess this code is being run directly from your plugin’s functions.php, meaning that you’re evaluating is_front_page() and is_archive() as you load the plugin. That’s too early – that’s before enough state has been initialised to know which page you’re on. To fix this, you either need to: move the logic into your say_hello functions, … Read more

How to check what kind of saving it is?

There are hooks specifically for this, actually. The codex has a pretty good overview. Essentially every time WordPress saves a post (which it does through wp_insert_post) or alters the status of the post, it calls wp_transition_post_status which looks like this: <?php // in wp-includes/post.php function wp_transition_post_status($new_status, $old_status, $post) { do_action(‘transition_post_status’, $new_status, $old_status, $post); do_action(“{$old_status}_to_{$new_status}”, $post); … Read more

How do I successfully create a hook for an email override?

WordPress uses the PHPMailer class for sending mail. Before calling wp_mail, you can manipulate the $phpmailer object using the phpmailer_init filter. //Place this inside of your form callback before wp_mail() add_filter(‘phpmailer_init’, ‘foobar_phpmailer’, 99999, 1); function foobar_phpmailer(&$phpmailer){ //Manipulate the phpmailer object here }

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