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
add_action( 'template_redirect', function() { | |
if ( is_singular( 'authors' ) ) { | |
global $wp_query; | |
$page = ( int ) $wp_query->get( 'page' ); | |
if ( $page > 1 ) { | |
// convert 'page' to 'paged' | |
$query->set( 'page', 1 ); | |
$query->set( 'paged', $page ); | |
} | |
// prevent redirect |
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 my_posts_where( $where ) { | |
$where = str_replace("meta_key = 'document_%", "meta_key LIKE 'document_%", $where); | |
return $where; | |
} | |
add_filter('posts_where', 'my_posts_where'); | |
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 | |
$course_terms = get_terms( array( | |
'taxonomy' => 'course_category', | |
'hide_empty' => false, | |
) ); | |
//fprint_r($course_terms); | |
foreach($course_terms as $course_term){ | |
$course_category_id = $course_term->term_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
//hook into the init action and call create_book_taxonomies when it fires | |
add_action( 'init', 'create_topics_hierarchical_taxonomy', 0 ); | |
//create a custom taxonomy name it topics for your posts | |
function create_topics_hierarchical_taxonomy() { | |
// Add new taxonomy, make it hierarchical like categories | |
//first do the translations part for GUI |
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 request_url() | |
{ | |
$result = ''; // Пока результат пуст | |
$default_port = 80; // Порт по-умолчанию | |
// А не в защищенном-ли мы соединении? | |
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS']=='on')) { | |
// В защищенном! Добавим протокол... | |
$result .= 'https://'; | |
// ...и переназначим значение порта по-умолчанию |
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
$app = Jfactory::getApplication(); | |
$input=$app->input; | |
if ($input->getCmd('option')=='com_content' | |
&& $input->getCmd('view')=='article' ){ | |
$cmodel = JModelLegacy::getInstance('Article', 'ContentModel'); | |
$catid = $cmodel->getItem($app->input->get('id'))->catid; | |
echo $catid; | |
} |
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
// 163 - necessary category id | |
// "category" - taxonomy name | |
$children_id = get_term_children(163, "category"); | |
foreach($children_id as $child){ | |
$term = get_term_by("id", $child, "category"); | |
$id = $term->term_id; | |
$name = $term->name; | |
$count = $term->count; | |
} |
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
$publicationsWithoutTerms = new WP_Query(array( | |
'post_type' => 'doc', | |
'tax_query' => array(array( | |
'taxonomy' => 'category', | |
'field' => 'term_id', | |
'operator' => 'NOT IN', | |
'terms' => get_terms('category', array( | |
'fields' => 'ids' | |
)) | |
)) |
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
#301 Redirects for .htaccess | |
#Redirect a single page: | |
Redirect 301 /pagename.php http://www.domain.com/pagename.html | |
#Redirect an entire site: | |
Redirect 301 / http://www.domain.com/ | |
#Redirect an entire site to a sub folder | |
Redirect 301 / http://www.domain.com/subfolder/ |