08 April 2020

How to use WP_Query with have_posts()?

How to use WP_Query with have_posts()?

global $wp_query;
$original_query = $wp_query;
$wp_query = null;
$wp_query = new WP_Query( $args );
if ( have_posts() ) :
    while ( have_posts() ) : the_post();
        the_title();
        the_excerpt();
    endwhile;
else:
    echo 'no posts found';
endif;
$wp_query = null;
$wp_query = $original_query;
wp_reset_postdata();
Get more detail from here

How to stop and pause youtue video in jquery?

How to stop and pause youtue video in jquery?



                               Html



<iframe width="560" height="315" src="https://www.youtube.com/embed/mKt-MDwtVB4" frameborder="0" allowfullscreen></iframe>

  <button class="fancybox-close">Stop video please</button>

<p>
http://stackoverflow.com/questions/8931798/hide-show-in-javascript-stop-playing-youtube-iframe-video

http://stackoverflow.com/questions/9482180/using-javascript-to-add-class-to-youtube-iframe-element

http://stackoverflow.com/questions/4249809/reload-an-iframe-with-jquery
</p>

                                   CSS


body {width:60%;margin:3em auto;}
footer {border-top:1px solid #ccc;padding:1em 0;}



jQuery


    // Finds all iframes from youtubes and gives them a unique class
    jQuery('iframe[src*="https://www.youtube.com/embed/"]').addClass("youtube-iframe");

    jQuery(".fancybox-close").click(function() {
      // changes the iframe src to prevent playback or stop the video playback in our case
      $('.youtube-iframe').each(function(index) {
        $(this).attr('src', $(this).attr('src'));
        return false;
      });
      
//click function
    });

28 March 2020

How to Get Category name from Post ID in wordpress?

Get Category name from Post ID

$category_detail=get_the_category('4');//$post->ID
foreach($category_detail as $cd){
echo $cd->cat_name;
}

21 March 2020

if jQuery contain and match value then replace with another value on load in jQuery?

if jQuery contain and match value then replace with another value on load in jQuery.




$(window).on("load", readyFn);
function readyFn() {
   $('#chart-container text').each(function() {
var ourText = $(this).text().toLowerCase(); // convert text to Lowercase
if(ourText.match('75%')) {
$(this).html( "h" );
}     
});

}

How to fix If value is infinity, empty and NaN in jQuery?

 fix If value is infinity, empty and NaN in jQuery

if (theResult == Infinity || theResult == "" || theResult == NaN) {
    theResult == 0;
}
$("#theResult").val(theResult);

19 March 2020

How to get Selected Option Text of HTML SELECT using jQuery?

Get Selected Option Text of HTML SELECT using jQuery


<select id="mySelect">
    <option value="1">hello</option>
    <option value="2">bro</option>
</select>
<input type="button" id="test" value = "test" />
<script type="text/javascript">
    $("#test").live("click", function () {
        
        var selectedText = $("#mySelect option:selected").html();
        alert(selectedText);
    });
</script>

18 March 2020

How to get full detail of any mobile number in cordova?

Get full detail of any mobile number in cordova.


document.addEventListener("deviceready", hello, false);
function hello(){
navigator.contacts.pickContact(function(contact){
 console.log('The following contact has been selected:' + JSON.stringify(contact));
 
document.getElementById("number").innerHTML = 'The following contact has been selected:' + JSON.stringify(contact);
    },function(err){
        console.log('Error: ' + err);
    });
}

How to fetch instagram posts data?

Fetch Instagram posts data by pasting this code in browser console. (() => { /* ====================================================...