Can I override the content array using the_posts filter?

The the_content filter will work for this. This filter allows you to alter the output of the_content() and get_the_content(): add_filter( ‘the_content’, ‘wpse_members_only’, 20 ); function wpse_members_only( $content ) { // If user is not logged in, show restricted content message. // Change this conditional statement based on how you want to check for // membership … Read more

How to add_filter to an OOP based apply_filter(‘foo::bar’, $a);

I’m not exactly sure where you’re having problems. Adding and removing hooks is the basis of WordPress programming. Once you understand the hook system, you’ll have a much easier time. What are hooks? Everything you need to get started is available at Plugin API/Hooks. WordPress has two types of hooks: actions and filters, but they’re … Read more

WordPress add script with custom type (x-jquery-tmpl)

Printing the script in the head is a method called do_item in the wp_script class. In this method you see this line: $tag = “{$cond_before}{$before_handle}<script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/262406/$src”></script>\n{$after_handle}{$cond_after}”; So, the script type is hardwired in the function. However, a few lines further on, you see this: $tag = apply_filters( ‘script_loader_tag’, $tag, $handle, $src ); This allows … Read more

How to filter link?

You have invalid PHP (which should have been obvious from the PHP error log). function review_link_custom( $link, get_the_ID(), $review_link, $instance[‘cwp_tp_readreview’] ) { Functions can have neither other functions nor array+key as an argument, you can only specify the name for an argument passed. Also, when adding a filter you have to specify how many arguments … Read more

How To Override A WooCommerce AJAX Function

Ok, so I don’t know if this is the best way, but it’s working for now. Within my OOP class (I have a custom plugin to override a WC plugin): remove_action( ‘wp_ajax_wc_function’, array( WC_Parent_Class, ‘wc_do_stuff’ ) ); remove_action( ‘wp_ajax_nopriv_wc_function’, array( WC_Parent_Class, ‘wc_do_stuff’ ) ); add_action( ‘wp_ajax_wc_function’, array( __CLASS__, ‘my_override_do_stuff’ ) ); add_action( ‘wp_ajax_nopriv_wc_function’, array( __CLASS__, … Read more

Excerpt is being added above the content, but it should be after it

You are echoing the content of the excerpt, which is being put into the header. Use get_the_excerpt() instead: function after_post_content($content){ if (is_single()) { $content .= get_the_excerpt(); } return $content; } add_filter( “the_content”, “after_post_content”); Generally, WordPress functions beginning with the_ will echo the output, while functions starting will get_the_… will get the value.

Filter for when the post is updated

The filter you are looking for is save_post. This filter is triggered each time you save a post. add_action( ‘save_post’, ‘my_function’ ); function my_function( $post_id ){ // Do your stuff here } This filter passes the post’s ID to the callback function, so you have access to everything you need.

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