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
query_posts('p=3547'); // - записи присвоен идентификатор, равный 3547. | |
if (have_posts()) : // - если есть вообще указанная запись. | |
while (have_posts()) : the_post(); // - начинаем традиционный цикл WordPress. | |
print '<div id="post-'; the_ID(); // - выводим ID записи и её класс. | |
print '"'; post_class(); print '>'; | |
print '<h4>'. get_the_title(). '</h4>'; // - выводим заголовок. | |
print get_the_content(); // - выводим содержимое. | |
print '</div>'; | |
endwhile; | |
endif; |
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 | |
$idObj = get_category_by_slug('s_about'); | |
$id = $idObj->term_id; | |
echo get_cat_name($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 if ( have_posts() ) : query_posts('p=1'); | |
while (have_posts()) : the_post(); ?> | |
<?php the_title(); ?> | |
<?php the_content(); ?> | |
<?php the_post_thumbnail(array(100, 100)); ?> | |
<?php endwhile; endif; wp_reset_query(); ?> |
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 wp_get_attachment_url( get_post_thumbnail_id( $post->ID ) ); ?> | |
//or | |
<?php wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 60,60 ), false, '' ); ?> | |
//or | |
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 300,300 ), false, '' ); echo $src[0]; ?> | |
//and | |
get_the_post_thumbnail( $id ); // без параметра $size |
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
//For the latest blog post: | |
<?php query_posts('showposts=1'); ?> | |
<?php while (have_posts()) : the_post(); ?> | |
<?php the_post_thumbnail(); ?> | |
<?php endwhile; ?> | |
//For a thumbnail from a particular page (in this case id =7 ): | |
<?php query_posts('page_id=7'); ?> | |
<?php while (have_posts()) : the_post(); ?> | |
<?php the_post_thumbnail(); ?> |
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
//WordPress has a few useful options, you can get the homepage ID by using the following: | |
$frontpage_ID = get_option('page_on_front'); | |
//or the Blog ID by using: | |
$blog_ID = get_option('page_for_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
function get_post_by_slug($slug, $post_type){ | |
$posts = get_posts(array( | |
'name' => $slug, | |
'posts_per_page' => 1, | |
'post_type' => $post_type, | |
'post_status' => 'publish' | |
)); | |
if( !$posts ) { | |
throw new Exception("NoSuchPostBySpecifiedID"); |
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
//====================================================================================================================== | |
// Google Maps Scripts <div id="acf-map" data-lat="12.345678" data-lng="12.345678"></div> | |
//====================================================================================================================== | |
function render_map($map_div) { | |
// var | |
var lat = $map_div.attr('data-lat'); | |
var lng = $map_div.attr('data-lng'); | |
// coordinates to latLng | |
var latlng = new google.maps.LatLng(lat, lng); | |
// map Options |
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
// get current taxonomy-slug in template taxonomy-{taxonomy}.php | |
$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); | |
echo $term->slug; | |
// get full info of taxonomy | |
$the_tax = get_taxonomy( get_query_var( 'taxonomy' ) ); | |
echo $the_tax->labels->name; | |
// get taxonomy-type current | |
echo get_query_var('taxonomy'); |
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<title>Photos with Friends!</title> | |
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script> | |
<script> | |
/** | |
* This is the getPhoto library | |
*/ |
OlderNewer