Active Sidebar Conditional Question?

If I am reading this right, all you need is a count of the active sidebars, so: $col = 0; if(is_active_sidebar(‘footer’)) { $col++; } if(is_active_sidebar(‘footer-2’)) { $col++; } if( is_active_sidebar(‘footer-3’)) { $col++; }?> <div class=”<?php echo ‘column-‘.$col; ?>”> Note: I flipped the “column” class so that it begins with a letter. Numbers are not allowed … Read more

how to run a php code in widget?

Try this with or without the return. $object_terms = wp_get_object_terms($GLOBALS[‘post’]->ID, ‘staff’, array(‘fields’ => ‘all’)); if ($object_terms) { echo ‘<p>’ . ” . ” ; $res=””; foreach ($object_terms as $term) { $res .= ‘<a href=”‘ . esc_attr(get_term_link($term, $taxonomy)) . ‘” title=”‘ . sprintf(__(“View artiles of: %s”), $term->name) . ‘” ‘ . ‘>’ . $term->name . ‘</a>, … Read more

widgets_init actions not fired from functions.php’s child theme

In your child theme’s ‘functions.php’ file, you need to use the remove_action( ‘widgets_init’, ‘$name’ ); script. For instance, in your twentytwelve-child theme’s functions.php file, use: remove_action( ‘widgets_init’, ‘twentytwelve_widgets_init’ ); //necessary to replace parent theme’s code and then hook your new widget in your child theme’s function add_action( ‘widgets_init’, ‘new_twentytwelve_widgets_init’, 0 );

Does current page contain widget or sidebar

Sidebars aren’t assigned to pages by means of, say, database entries or any other means that PHP can detect easily. Sidebars just run where a function call tells them to run. You can’t really query to see if a sidebar is on a particular page because there is nothing to query. Well, almost nothing. The … Read more

Loop doesn’t work

This should work (if your post_type is not post you will need to amend the code) <?php $args = array( ‘post_type’ => ‘post’, ‘cat’ => ’31’, ‘posts_per_page’ => 5, ); $query = new WP_Query( $args );?> <?php if( $query->have_posts() ) : ?> <?php while( $query->have_posts() ) : $query->the_post(); ?> <li><a href=”https://wordpress.stackexchange.com/questions/209558/<?php the_permalink(); ?>”><i class=”fa fa-book”></i> … Read more

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