How to remove ‘ P ‘tags from images in WordPress


Removing  <p> tags from images in WordPress

Please add below code in function.php


function img_unautop($pee) {
    $pee = preg_replace('/<p>\\s*?(<a .*?><img.*?><\\/a>|<img.*?>)?\\s*<\\/p>/s', '<div class="figure">$1</div>', $pee);
    return $pee;
}
add_filter( 'the_content', 'img_unautop', 30 );
Advertisements

How to get Custom Menu in Query Posts WordPress


<?php
    $args = array(
    'post_type' => 'nav_menu_item', 'orderby'   => 'menu_order',
    'order'  => 'ASC',
    'tax_query' => array(
        array(
            'taxonomy' => 'nav_menu', 'field' => 'slug', 'terms' => 'my'        
        )
    )
);
query_posts($args);
while( have_posts()):the_post();
echo $post->ID;
endwhile; wp_reset_query();?>