Get post format and use it as a CSS class in different spans

Every post has a maximum of one format and one status. To echo the format you need: if (get_post_format($post->ID)) echo ‘<span class=”format-‘ . get_post_format($post->ID); . ‘”></span>’; To echo the status you need this: if (get_post_status($post->ID)) echo ‘<span class=”status-‘ . get_post_status($post->ID); . ‘”></span>’; Hopefully this is what you need.

Using transient for dynamic css , how to name it?

Unless you do something weird with your settings, transients will just make your code harder to read without adding any measurable performance value. People that want performance should use object caching and page caching and your current code is probably already the best there is to utilize them. Transients will add almost nothing for them. … Read more

Advanced: understanding wp_add_inline_style function

Check if the following works for you. Just adapt the is_single() to is_singular(‘custom-post-type’) if you want this on a single custom post type template specifically. Hope this helps. function bootstrap_scripts_styles() { wp_enqueue_style(‘custom-style’,get_template_directory_uri() . ‘/bootstrap.css’); $custom_css = “.intro { background: red; }”; wp_add_inline_style( ‘custom-style’, $custom_css ); } function enqueue_inline_style( $query ) { if ( $query->is_single()) { … Read more

Child Theme CSS not showing at all

Please use this instead of what you are using. This will definitely work. <?php function my_theme_enqueue_styles() { $parent_style=”parent-style”; // This is ‘twentyfifteen-style’ for the Twenty Fifteen theme. wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ ); wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ), wp_get_theme()->get(‘Version’) ); } add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ ); ?> For more details on configuring Child … Read more

Page layout is broken when viewing search results.

Check out the markup. On the search results page, the <body> element is assigned the classes search and search-no-results. <body class=”search search-no-results”> Looking at the CSS, the styles for .search are intended to be used for the search input. They are working for that, but they are also being applied to the body due to … Read more

Adding Custom css file

Put this code in functions.php file for add new css file (more info here). add_action( ‘wp_enqueue_scripts’, ‘enqueue_my_styles’ ); function enqueue_my_styles() { wp_enqueue_style( ‘my-theme-ie’, get_stylesheet_directory_uri() . “/css/ie.css”); } if using a parent theme then put code in parent theme function.php file and use get_template_directory_uri() if using a child theme then put code in child theme function.php … Read more

Sidebar button click redirect when user is not logged in instead displays it

when you want interaction between client side and server side you should use ajax . i think this Link will be very helpful to you 🙂 Put this in your javascript var data = { action: ‘is_user_logged_in’ }; jquery.(‘.x-btn-widgetbar’).on(‘click’,function(){ jQuery.post(ajaxurl, data, function(response) { if(response == ‘yes’) { // user is logged in, do your stuff … Read more

Keeping CSS model open after form submission

A combination of PHP and JS will do it. Have your page listen for the presence of gform_submit which Gravity Forms includes as a hidden field on all forms by default. if(!empty($_POST[‘gform_submit’])) { // now here comes your javascript } For the JS, set modal-state checked. This way on page load, if the form has … Read more

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