Monthly Archives: May 2016

Is it a subpage of the page id 129?

So in your functions.php file:
**
 * Check whether we are on a subpage
 *
 * @return mixed ID of the parent post or false if this is not a subpage.
 */
function wpdocs_is_subpage() {
    // Load details about this page.
    $post = get_post();
 
    // test to see if the page has a parent
    if ( is_page() && $post->post_parent ) {
        // Return the ID of the parent post.
       return $post->post_parent;
    // There is no parent so ...
    } else {
        // ... The answer to the question is false
          return false;
    }
   
}

 
And in your page.php or where ever:

 

 
Source

Displaying year on your website with JavaScript and jQuery

In HTML-part:

2016

 
In JavaScript, if the year is the same as the first year (in our example 2016) - we won't display it:
(function() {

			
	var dateNow = new Date();
	var thisYear = dateNow.getFullYear();
	var changeText = document.getElementById("js-year");

	if (thisYear != "2016"){
	
		changeText.innerHTML = ' - ' +thisYear;
	}
})();
 
And in jQuery:
$(document).ready(function(){
			
var dateNow = new Date()
	var thisYear = dateNow.getFullYear();

	if (thisYear != "2016"){
	
		$("#js-year").text(' - ' +thisYear);
	}

			
});

Hiding email from spam-bots

In your HTML:

Here is JavaScript's part:




Ok, and now jQuery's version:
emailE=('mail@' + 'mal.com');
var neededDiv =  ('#js-m-pr');
if($(neededDiv)!=null){
 $(neededDiv).html('' + emailE + '');
}

source

Get subpages’ title and content

 'page',
    'posts_per_page' => -1,
    'post_parent'    => $post->ID,
    'order'          => 'ASC',
    'orderby'        => 'menu_order'
 );


$parent = new WP_Query( $args );

if ( $parent->have_posts() ) : ?>

    
    have_posts() ) : $parent->the_post(); ?>
	
        

Month’s first and last day

How to get month's first and last day in case you have your own variables? $month = 5; $full_year = 2016; For first day we can use: date("01.$month.$full_year"); // 01.05.2016 And for the last year: date("t.$month.$full_year"); // 31.05.2016