Some questions regarding filter

It depends whether you’re trying to hook to an existing filter or hook to one you’ve made, looking at your second code sample suggests you’re asking about making your own filter. And, yes you can add your own, something like this is valid inside your loop. <?php echo apply_filters( ‘my_blah_filter’, ‘<p>Blah blah some text goes … Read more

Can’t change the title tag with wp_title filter

When adding title-tag support in a theme, the title tag can be filtered by several filters, but not wp_title. The reason is that if the theme supports title-tag, WordPress uses wp_get_document_title() instead of wp_title(). For themes with support for title-tag you can use document_title_parts: add_filter( ‘document_title_parts’, ‘filter_document_title_parts’ ); function filter_document_title_parts( $title_parts ) { $title_parts[‘title’] = … Read more

Filter the blog’s title without using global variables

You can encapsulate the logic in a class: class NameSwitch { private $state = false; private $string; public function __construct( $string ) { $this->string = $string; } public function change_state() { $this->state = ! $this->state; return $this->state; } public function replace( $output, $show = NULL ) { if ( ‘name’ !== $show ) return $output; … Read more

Format content value from DB outside of WordPress filters

There are a few filters and actions here that run. You’d need to look at the code and figure out what/how to utilize these. https://codex.wordpress.org/Function_Reference/wpautop https://codex.wordpress.org/Function_Reference/wptexturize https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content https://developer.wordpress.org/reference/functions/do_shortcode/ https://developer.wordpress.org/reference/functions/unescape_invalid_shortcodes/ https://developer.wordpress.org/reference/functions/get_shortcode_regex/

End excerpt at the end of the sentence

Use this function instead. Then put the_excerpt(); in your template. /** * Find the last period in the excerpt and remove everything after it. * If no period is found, just return the entire excerpt. * * @param string $excerpt The post excerpt. */ function end_with_sentence( $excerpt ) { if ( ( $pos = mb_strrpos( … Read more

Please explain me what the do_action does

If you hook some functions to the before_sidebar action, they will be executed in your code. Your action is now probably without any function hooked, so it returns nothing. Example: <?php add_action( ‘before_sidebar’, function() { echo ‘Try me!’; }); add_action( ‘before_sidebar’, function() { echo ‘Yep. ‘; }, 1); // this should output “Yep. Try me!” … Read more

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