How do I assign this filter to a variable? (Appending php & markup to the_content)

Congratulations on (nearly) solving your problem already 🙂 There are 2 comments below the post that attempt to say how to do it the right way They are proposing to do it this way: function weedub_affiliate_filter($content) { $string_to_add = ”; if (is_single()) { $string_to_add = $string_to_add . ‘the string you wanted to add’; } $content … Read more

Manipulating cookie on specific taxonomy archive page

After googling around I found the correct way to do it by using the ‘wp’ hook if (is_tax(‘term-country’)) add_action(‘wp’, ‘my_setcookie’); // my_setcookie() set the cookie on the domain and directory WP is installed on function my_setcookie(){ $path = parse_url(get_option(‘siteurl’), PHP_URL_PATH); $host = parse_url(get_option(‘siteurl’), PHP_URL_HOST); $expiry = strtotime(‘+1 month’); setcookie(‘location’, ‘my_cookie_value_3’, $expiry, $path, $host); }

is_archive() doesn’t work on public query var archive pages?

Try this: add_action( ‘template_redirect’, ‘my_test_if_archive’ ); function my_test_if_archive() { global $wp_query; $qv = array_keys( $wp_query->query ); $archives = array(‘year’, ‘monthnum’, ‘day’, ‘w’, ‘m’, ‘author’, ‘post_type’); $is_archive = ! empty( array_intersect( $qv, $archives ) ); $is_tax = ! empty( $wp_query->tax_query->queries ); if ( $is_archive || $is_tax ) { // this is an archive } }

Apply the_title filter to post titles AND backend auto social-sharing plugin, but not nav menu

Solution function append_album_review_to_title( $title, $id = NULL ) { if ($id) { if ( get_post_type( $id ) == ‘album_review’ ){ return ‘Album Review: ‘ . $title; } else { return $title; } } else { return ‘Album Review: ‘ . $title; }; } add_filter(‘the_title’, ‘append_album_review_to_title’, 10, 2); Explanation First trying this: function append_album_review_to_title( $title, $id … Read more

is_home() vs is_archive()

To properly understand the difference, you have to dig into the WordPress Core is_archive() (defined in wp-includes/query.php#L140) checks any type of archive page. These archive pages is defined in the WP_Query class in wp-includes/query.php#L1615 lines 1615 and line 1616 1615 if ( $this->is_post_type_archive || $this->is_date || $this->is_author || $this->is_category || $this->is_tag || $this->is_tax ) 1616 … Read more

what is the action hook code to supporting product category condition in single product page of woocommerce?

Firstly, this conditional returns true on category archives for Woo Commerce and NOT single product page. Try using the actual slug in lowercase or the i.d. Example: if ( is_product_category( ‘t-shirt’ ) ) { Your code looks like its wrong because it includes too many brackets. Woo suggest using the slug in their Docs. This … Read more

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