$related = new WP_Query( ( array( 'category__in' => wp_get_post_categories($post->ID), 'posts_per_page' => 5, 'post__not_in' => array($post->ID) ) );
if( $related->have_posts() ) {
while( $related->have_posts() ) { $related->the_post();
the_title();
}
}
wp_reset_postdata();
public function register_scripts() {
$script_path = WP_TILES_ASSETS_URL . 'js/';
$in_footer = apply_filters( 'wp_tiles_js_in_footer', true );
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
wp_register_script( 'tilesjs', $script_path . 'tiles.js', array( "jquery" ), "2013-05-18", $in_footer );
wp_register_script( 'jquery-dotdotdot', $script_path . 'jquery.dotdotdot.js', array( "jquery" ), "1.6.14", $in_footer );
wp_register_script( 'wp-tiles', $script_path . 'wp-tiles.js', array( "jquery", "tilesjs", "jquery-dotdotdot" ), WP_TILES_VERSION, $in_footer );
} else {
wp_register_script( 'wp-tiles', $script_path . 'wp-tiles.min.js', array( "jquery" ), WP_TILES_VERSION, $in_footer );
}
}
public function register_styles() {
$stylesheet = WP_TILES_ASSETS_URL . 'css/wp-tiles.css';
// In admin we want vanilla WP Tiles styles
if ( !is_admin() ) {
/**
* Get the WP Tiles stylesheet
*
* @since 1.0
* @param string Stylesheet location or false to disable separate css
*/
$stylesheet = apply_filters( 'wp_tiles_stylesheet', $stylesheet );
if ( false === $stylesheet )
return;
}
wp_register_style( 'wp-tiles', $stylesheet, false, WP_TILES_VERSION );
/**
* Always enqueue stylesheet or defer loading until an instance of
* WP Tiles has been detected
*
* @since 1.0
* @param bool Always enqueue
*/
if ( !is_admin() && apply_filters( 'wp_tiles_always_enqueue_stylesheet', false ) ) {
$this->enqueue_styles();
}
}
public function enqueue_scripts() {
wp_enqueue_script( 'wp-tiles' );
$this->add_action( 'wp_footer', 'add_data', 1 );
}
public function enqueue_styles() {
wp_enqueue_style( 'wp-tiles' );
do_action( 'wp_tiles_enqueue_styles' );
}
$wpTiles = new WPTiles/WPTiles;
$wpTiles->register_scripts();
$wpTiles->register_styles();
$wpTiles->enqueue_scripts);
$wpTiles->enqueue_styles();
$script_path = путь-к-папке-с-скриптом
...
wp_register_script( 'tilesjs', $script_path . 'tiles.js', array( "jquery" ), "2013-05-18", $in_footer );
...
use yii\data\Pagination;
$query = Article::find()->where(['status' => 1]);
$count = $query->count();
$pagination = new Pagination(['totalCount' => $count]);
$articles = $query->orderBy('id DESC')->offset($pagination->offset)
->limit($pagination->limit)
->all();
UPDATE tbl SET
`date` = CONCAT('20',SUBSTRING(`date`,7,2),'-',SUBSTRING(`date`,3,2),'-',SUBSTRING(`date`,0,2))
WHERE date LIKE '__.__.__'
;
SELECT
CONCAT('20',SUBSTRING(`date`,7,2),'-',SUBSTRING(`date`,3,2),'-',SUBSTRING(`date`,0,2)) as date
FROM tbl
WHERE date LIKE '__.__.__'
;
$res = mysql_query(...)
if ($res === FALSE) {
die( mysql_error() );
}
Для запросов SELECT, SHOW, DESCRIBE, EXPLAIN и других запросов, возвращающих результат из нескольких рядов, mysql_query() возвращает дескриптор результата запроса (resource), или FALSE в случае ошибки.
Для других типов SQL-запросов, INSERT, UPDATE, DELETE, DROP и других, mysql_query() возвращает TRUE в случае успеха и FALSE в случае ошибки.
Полученный дескриптор результата нужно передать в функцию mysql_fetch_assoc() или любую другую функцию, работающую с результатами запросов.
Используйте mysql_num_rows() для выяснения количества рядов в результате SELECT-запроса или mysql_affected_rows() для выяснения количества обработанных рядов запросами DELETE, INSERT, REPLACE и UPDATE.
mysql_query() также завершится с ошибкой и вернет FALSE, если у пользователя нет доступа к какой-либо из таблиц, фигурирующих в запросе.
<?php
if (is_category([16,25,26])) {
include dirname(__FILE__).'/single-A.php';
} elseif (is_category([18,24])) {
include dirname(__FILE__).'/single-B.php';
} else {
include dirname(__FILE__).'/single-default.php';
}
$('#btn').click(function(){
....
// проверка каптчи
// показ ошибки или скачивание файла
....
});
$('#btn').click(function(){
....
if (!valid_captcha()) return false;
// показ ошибки или скачивание файла
....
});
function valid_captcha(){
var ret = false;
// проверка каптчи
return ret;
}
Content-Type application/octet-stream
<form action="http://google.com">
<input type="submit">
</form>
<script>
$('form').first().submit(function(){
if (!confirm('Submit form?')) return false;
});
</script>