Replace word in “the_content” only for index.php

Few possibilities here: In index.php you find the_content() and replace it with: $content = get_the_content( $more_link_text, $strip_teaser ); $content = apply_filters( ‘the_content’, $content ); $content = str_replace( ‘]]>’, ‘]]>’, $content ); $replace = array( ‘autoplay=””‘ => ” ); $text = str_replace(array_keys($replace), $replace, $text); echo $text; Did you try putting that bit of code in index.php? … Read more

Show MySQL errors that occur when I excute $wpdb->insert()

This doesn’t answer your question directly, but the solution here is to validate the data before you chuck it at the database and pray. Sending bad data ‘down the line’ so that something else can check it and report back to you if it wasn’t what they were expecting is bad design. You don’t know … Read more

allow subscribers to see private posts without plug in

This can be added as a basic hook – function what-ever-youwantto-callthis() { $subRole = get_role( ‘subscriber’ ); //change the name of the user here $subRole->add_cap( ‘read_private_posts’ ); //allows the above to read posts $subRole->add_cap( ‘read_private_pages’ ); //allows the above to read pages } add_action( ‘init’, ‘what-ever-youwantto-callthis’ );

Programmatically add and remove woocommerce product category

Add the codes below to a custom plugin To add the category to new products function set_new_product_cat( $post_id, $post, $update ) { if(“product” === $post->post_type){ // Exit out as we are updating an existing product if ( $update ) { return; } //Appends the category 35 to the product wp_set_post_categories( $post->ID, 35, true); } } … Read more

Using file_get_contents with Gravity Forms uploads folder to create images in the media library returning false

I noticed in your comment… Return the uploaded image ID, so to use to update the ACF field Here is two functions which may help you out… gf_handle_attachments() to handle converting gform submission image file into wordpress media attachment. Returning media (attachment) id. gf_upload_to_media_acf() to handle gform submitted image or multiple images and update defined … Read more