term_id, $term->taxonomy ); if (sizeof($term_children)==0){ // if category has no children, we won't make a link ?>name; ?>
} else { // if catergory has childre, we ask a link $term_link =get_term_link($term); ?>name ?>
Get term link
$term_link = get_term_link($term);
Is it a subpage of the page id 129?
So in your functions.php file:
And in your page.php or where ever:
Source
** * 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; } }
Displaying year on your website with JavaScript and jQuery
In HTML-part:
In JavaScript, if the year is the same as the first year (in our example 2016) - we won't display it:
And in jQuery:
2016
(function() { var dateNow = new Date(); var thisYear = dateNow.getFullYear(); var changeText = document.getElementById("js-year"); if (thisYear != "2016"){ changeText.innerHTML = ' - ' +thisYear; } })();
$(document).ready(function(){ var dateNow = new Date() var thisYear = dateNow.getFullYear(); if (thisYear != "2016"){ $("#js-year").text(' - ' +thisYear); } });
If url contains a string
In PHP:
Hiding email from spam-bots
In your HTML:
Here is JavaScript's part:
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 + ''); }
Get subpages’ title and content
Finding match that starts with
Similar to CSS:
$('[id^="match_"]').click(function({ $(this).find('element').whatEverComesNext(); });
Finding files quickly
In Sublime you can use:
Ctrl+p
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