get_the_archive_title hook unwanted changes!

You could do something like this to see where it was called from: add_filter(“get_the_archive_title”, function($val) { $backtrace = debug_backtrace(); foreach($backtrace as $level) { if(array_key_exists(“file”, $level) && preg_match(“!that-file\.php$!”, $level[“file”]) && array_key_exists(“function”, $level) && $level[“function”] == “get_the_archive_title” ) { return “works: $val”; } } return “test: $val”; }, 10, 1); You’ll have to adapt the regexp (“that-file.php”) … Read more

Cutting off excerpt with first sentence

Try the solution by @Pieter Goosen i found for me it was the best solution, and it easy to customise. if ( ! function_exists( ‘pietergoosen_custom_wp_trim_excerpt’ ) ) : function pietergoosen_custom_wp_trim_excerpt($pietergoosen_excerpt) { global $post; $raw_excerpt = $pietergoosen_excerpt; if ( ” == $pietergoosen_excerpt ) { $pietergoosen_excerpt = get_the_content(”); $pietergoosen_excerpt = strip_shortcodes( $pietergoosen_excerpt ); $pietergoosen_excerpt = apply_filters(‘the_content’, $pietergoosen_excerpt); … Read more

Apply a filter str_replace on specific caracters array in the_content()

You could obtain what you need like this: function str_replace_special_caracter($content) { // My array of special caracters to get <sup> $specialCaracters = array(‘®’, ‘™’); foreach( $specialCaracters as $character ){ $content = preg_replace( ‘@(‘ . preg_quote( $character, ‘@’ ) . ‘)@i’, “<sup>\\1</sup>”, $content ); } // Return return $content; } add_filter( ‘the_content’, ‘str_replace_special_caracter’, 99 );

Modify wp headers on specific page

from How can I change HTTP headers only to posts of a specific category from a plugin: add_action( ‘template_redirect’, ‘update_header_cache’ ); function update_header_cache() { if( is_single( 1234) ) { header(‘Cache-Control: no-store, no-cache, must-revalidate, max-age=0’); header(‘Pragma: no-cache’); header(‘Expires: Thu, 01 Dec 1990 16:00:00 GMT’); } }

Add option to query string before get_posts() is called on archive.php

function rpf_add_query_var_not_to_show_user_request_product($query) { $post_type = $query->get( ‘post_type’ ); if ( ! is_null($post_type) && $post_type == ‘product’ ) { $query->set( ‘meta_key’, ‘_user_request’ ); $query->set( ‘meta_value’, ‘no’ ); $query->set( ‘meta_compare’, ‘=’ ); // default } } add_action( ‘pre_get_posts’, ‘rpf_add_query_var_not_to_show_user_request_product’, 100, 1 ); yes, pre_get_posts is heaven! and $query->set(), $query->get() are angels!