<?php
global $wp_query; // you can remove this line if everything works for you
// don't display the button if there are not enough posts
if ( $wp_query->max_num_pages > 1 )
echo '<div class="misha_loadmore">More posts</div>'; // you can use <a> as well
?>
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tirarAcentos($string){ | |
$string = preg_replace(array("/(á|à|ã|â|ä)/","/(Á|À|Ã|Â|Ä)/","/(é|è|ê|ë)/","/(É|È|Ê|Ë)/","/(í|ì|î|ï)/","/(Í|Ì|Î|Ï)/","/(ó|ò|õ|ô|ö)/","/(Ó|Ò|Õ|Ô|Ö)/","/(ú|ù|û|ü)/","/(Ú|Ù|Û|Ü)/","/(ñ)/","/(Ñ)/","/(ç)/","/(Ç)/"),explode(" ","a A e E i I o O u U n N c C"),$string); | |
$char = array(' & ', 'ª ', ' (', ') ', '(', ')', ' - ', ' / ', ' /', '/ ', '/', ' | ', ' |', '| ', ' | ', '|', '_', '.', ' '); | |
return strtolower(str_replace($char, '-', $string)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function implements a "Load More" button. | |
// It assumes that there is already a matching query that has executed on the page, so this AJAX call is just a continuation of that query to grab additional posts. | |
// There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page) | |
$(function() { | |
// Grab the load more button, since I only want to run the code if the button is on the page | |
var loadMoreButton = $('#load-more'); | |
if (loadMoreButton) { | |
// Because there are already posts on the page, we need to manually tell this query what page of results to grab so that is doesn't load duplicate posts | |
var loadPosts = function(page) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"new_version":"1.0.0", | |
"url":"http://www.domain.com/theme-name/changelog", | |
"package":"http://www.domain.com/theme-name/themes.zip" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in the loop | |
$category = get_the_category(); | |
$currentcat = $category[0]->cat_ID; | |
$currentcatname = $category[0]->cat_name; | |
$currentcatslug = $category[0]->slug; | |
// outside the loop | |
global $post; | |
$categories = get_the_category($post->ID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function tag_cloud_shortcode($atts) { | |
// first make sure we are within a category | |
if (is_category()) { | |
// get info of current category | |
$category = get_category( get_query_var( 'cat' ) ); | |
// get current category ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Standard API query arguments | |
$args = array( | |
'orderby' => 'title', | |
'per_page' => 3 | |
); | |
// Put into the `add_query_arg();` to build a URL for use | |
// Just an alternative to manually typing the query string | |
$url = add_query_arg( $args, rest_url('wp/v2/posts') ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function uses AJAX to run a query. | |
// It assumes that there are no posts on the page, and they will be loaded by the user on demand. | |
// // There are no animations added here. For a smoother experience, it is a good idea to add animations to the button (ex. a loading icon during the request), or making the new posts animate in (ex, using Animate.css to fade them into the page) | |
$(function() { | |
// Grab the load button, since I only want to run the code if the button is on the page | |
var ajaxButton = $('#ajax-button'); | |
if (ajaxButton) { | |
// The AJAX request | |
var getPosts = function() { |
OlderNewer