help to remove last trailing slash using add_rewrite_rule

Replace all your above code with the one below: <?php function master_load_ads_txt_template_include( $template ) { $is_load_ads_txt = (bool) get_query_var( ‘ads-txt’ ); if ( $is_load_ads_txt ) { $template = locate_template( ‘template-parts/ads-txt.php’ ); } return $template; } add_filter( ‘template_include’, ‘master_load_ads_txt_template_include’ ); function master_load_ads_txt_rewrite() { add_rewrite_rule( ‘ads.txt’, ‘index.php?ads-txt=true’, ‘top’ ); // The line below doesn’t work and it’s … Read more

Pass PHP through redirect and custom fields

Without touching rewrites – you could probably do somthing like website.com/?goto-amazon=<?php echo get_the_ID() ?> Which’ed output website.com/?goto-amazon=42 Where 42 is an example of a post that contains the amazon_keywords. In your site you could listen for the goto-amazon query and redirect thereafter add_action( ‘init’, function(){ if (isset($_GET[‘goto-amazon’])) { $keywds = get_field(‘amazon_keywords’,intval($_GET[‘goto-amazon’])); $link = “http://www.amazon.co.uk/s/?_encoding=UTF8&camp=1634&creative=19450&field-keywords={$keywds}&linkCode=ur2&tag=AFFID”; wp_redirect($link); … Read more

htaccess redirect throws an error: PHP Catchable fatal error: Object of class WP_Error could not be converted to string

They aren’t really connected. It’s just a redirect after all. The error means that some code in your website wrongly passes a WP_Error object to wp_kses_no_null(). In your position I’d put something like this into this function for debugging: if ( is_wp_error( $string ) ) { var_dump( $string ); debug_print_backtrace(); } This way you can … Read more

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