Clearfix Shortcode

Here’s the code to be added to functions.php. As a bonus I’ve included a shortcode for a horizontal rule <hr>: function shortcode_hr() { return ‘<hr>’; } function shortcode_clearfix() { return ‘<div style=”display: block; visibility: hidden; clear: both; height: 0;”></div>’; } function register_shortcodes() { add_shortcode(‘hr’, ‘shortcode_hr’); add_shortcode(‘clearfix’, ‘shortcode_clearfix’); } add_action( ‘init’, ‘register_shortcodes’); Nothing complicated here, so … Read more

Two column layout in WordPress?

This is not really a WordPress question but my first plugin solution is a “WordPress” way to do it. My other solutions are more general web design. I’m also making the assumption that you have some experience with custom templates/scripts. If you want to manually do it you can use something like Grid Columns This … Read more

Different layout based on post amount?

for a standard query, you can check the amount of posts with: all posts for the query: $wp_query->found_posts and the posts on the page: $wp_query->post_count use that with a conditional statement to switch to the different layouts. example: <?php if ( have_posts() ) : //start of the loop// if ( $wp_query->found_posts <= 4 ) { … Read more

How can I list posts with different formats depending on order?

WP_Query will track which post is current. For example: $p = new WP_Query(array(‘post_type’=>’post’,’posts_per_page’=> 10)); if ($p->have_posts()) { while ($p->have_posts()) { $p->the_post(); echo $p->current_post.'<br>’; } } You could use that to selectively format your posts. For example $p = new WP_Query(array(‘post_type’=>’post’,’posts_per_page’=> -1)); if ($p->have_posts()) { while ($p->have_posts()) { $p->the_post(); switch ($p->current_post) { case 0: case 3: … Read more

What are the default breakpoints set in WordPress?

The widths of the preview window in the Customiser when selecting the tablet and mobile device previews are 720px and 320px respectively. These are only defined in CSS, so there’s no hook or anything for specifically overwriting those sizes. The original styles are defined in /wp-admin/css/themes.css, and look like this: .preview-mobile .wp-full-overlay-main { margin: auto … Read more

Migrating to WordPress – but how will it do “structured” data?

Structured, as you named it, data in WordPress is combination of following features: [custom] post type – more accurately described as content type, you can register custom instead of bending generic “post” post type; taxonomies – for organizing posts into groups (native “category” and “tag” are taxonomies); custom fields – for storing bits of data … Read more

Function result goes outside div

You’re using a mix of echoing and returning. Here you’re starting by echoing: echo ‘<div class=”clear”></div>’; Here you’re putting the output into a variable (correctly): $output=”<div class=”row”>”; And here you’re just writing the content in quotes without echoing or assigning to a variable: ‘<div class=”col-md-8 grid-entry-wrapper”> <!– grid-entry-wrapper open –> <!– BLOG LOOP –> </div><!– … Read more

Wp admin – Set default value to 999 in comments

You can use add_filter(‘edit_comments_per_page’, ‘return_999’); function return_999(){ return 999; } since the user options are filtered in the WP_List_Table::get_items_per_page() class method : /** * Get number of items to display on a single page * * @since 3.1.0 * @access protected * * @return int */ function get_items_per_page( $option, $default = 20 ) { $per_page … Read more

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