How can I check the rewrite slug of current post type listing page

Looking to the problem from a different perspective, I’ve reached to a different solution to it. I’ve created a function to check the post type instead of checking the slug of the post type. Actually I was trying to assign different CSS Class to each post type add_action( ‘css_class_per_post_type’, ‘assign_css_class_to_each_post_type’ ); // to be called … Read more

Adding if statement

I have format your code and break echo statement into parts and add if condition. you can take reference from below code. <?php if ( is_user_logged_in() ) { echo ‘<ul style=”padding: 0; margin: 0;”> <li class=”adminBar” style=”float: left; line-height: 60px; border-left: 1px solid #555555; border-right: 1px solid #555555;”><a href=”#” target=”_blank”><img src=”#” height=”40px” style=”padding-left: 15px; padding-right: … Read more

Conditional formatting on data fetched from MYSQL

First a few notes: Shortcodes do accept arguments, so you could write [marks subject=”Biology”] (@see https://codex.wordpress.org/Shortcode_API) You should never ever pass raw data directly into a SQL statement, WordPress uses PDO, this means you can prepare statements. (@see https://developer.wordpress.org/reference/classes/wpdb/prepare/) Using the get_results will return an Array, object or null (@see https://developer.wordpress.org/reference/classes/wpdb/get_results/). There are many approaches … Read more

How can i conditionally load taxonomy-{taxonomy}.php template php files through functions.php

Find the solution 🙂 Code: if ($moviewp_comments == 1) { add_filter( ‘template_include’, ‘wpse_template_include’ ); function wpse_template_include( $template ) { // Handle taxonomy templates. $taxonomy = get_query_var( ‘taxonomy’ ); if ( is_tax() && $taxonomy ) { $file = get_theme_file_path() . ‘/templates/taxonomy-‘ . $taxonomy . ‘.php’; if ( file_exists( $file ) ) { $template = $file; } … Read more

Loading a stylesheet conditionally & verifying CSS

If you want to load something on the archive page than, You should use is_archive() rather than is_page( ‘archived-posts’ ), and after that, you can use the keyboard command Ctrl + u to check view source of chrome. Thereafter, use command Ctrl + f to search ‘arch-post-stylesheet’css handle’ (Don’t forget to remove quotes while searching).

Custom wp_query inside a conditional stament inside a template part doesn’t work: why?

You have assigned the queries result inside the first condition. So the values assigned to this variable “cm_offerta_post_figli” won’t be accessible inside the second elseif condition. Please put the below code on the top of First condition. It will work. <?php $cm_offerta_post_figli = new WP_Query( array( ‘post_type’ => ‘cm_offerta’, ‘post_parent’ => get_the_ID(), ‘order’ => ‘ASC’, … Read more

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