Add code to the header of posts by particular author

is_author() is not for determining current user, it checks whether the Author archive page is in display or not. Your call would be to use wp_get_current_user() or get_current_user_id() (if you are comfortable with user ID) or any similar function WP have. Example of using wp_get_current_user() <?php $current_user = wp_get_current_user(); if ( ‘ritesh’ === $current_user->user_login ) … Read more

Content visibility condition based on date

To display posts published in the last 30 days, you can pass the “date_query” argument inside WP_Query as follows. $getPosts = new WP_Query( array( “date_query” => array( “column” => “post_date_gmt”, “after” => “1 month ago”, ), ) ); You can read more about WP_Query on WP_Query | Class | WordPress Developer Resources

is_product_category(‘Services’) not working

You can use below code to hide add to cart & price for WooCommerce products in the ‘Services’ category. // Specific product category archive and shop pages add_action( ‘woocommerce_after_shop_loop_item_title’, ‘hide_loop_product_prices’, 1 ); function hide_loop_product_prices(){ global $product; if (! is_user_logged_in()) { if( is_product_category(‘services’) || has_term( ‘services’, ‘product_cat’, $product->get_id() ) ){ // Hide prices remove_action(‘woocommerce_after_shop_loop_item_title’, ‘woocommerce_template_loop_price’, 10 … Read more

Regarding Tags And Categories

Based on the image you posted on your questions comments, I would assume the Videos, Blog, and Photos are custom post types registered by your current theme. The theme might also register some custom taxonomies for the post types. The post types and taxonomies could also be registered by some theme related plugin. You should … Read more

is_tax() conditional tag not working

I found the solution to this, the is_tax(); method needs two arguments – the taxonomy and the term itself, so it should have been: is_tax(‘news_categories’, ‘web’) Just as an extra point the is_archive(‘sites’) should also have been is_post_type_archive(‘sites’)

Conditionally load public and admin code with AJAX working on both sides

I managed to resolve this issue by also checking for public interface. I created new function isPublic() to check if it is public. So here is my final code: if ($this->isPublic()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘public/class-public.php’); $this->Public = new Public(); } elseif ($this->isAdmin()) { require_once(plugin_dir_path(dirname(__FILE__)) . ‘admin/class-admin.php’); $this->Admin = new Admin(); } and here are helper … Read more

Enqueue script if not page template

You need to pass it as a function, or you already have but didn’t copy the whole code? If you did not do it, it should look something like this function page_template_not_enqueue() { if ( !is_page_template( ‘page-full-width.php’ ) ) { wp_enqueue_script( ‘flickity-js’, get_template_directory_uri() . ‘/js/flickity.js’, array(), filemtime( get_stylesheet_directory() . ‘/js/flickity.js’ ), true ); } } … Read more

How can i create a function tag in my plugin

You are looking for Enclosing Shortcode. Here is an example of how you can achieve this. function example_shortcode($atts = [], $content = null) { // do something to $content // run shortcode parser recursively $content = do_shortcode($content); // always return return $content; } add_shortcode(‘example’, ‘example_shortcode’); Now you can use it like [example] Here is my … Read more

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