$cat = new WPSEO_Primary_Term('category', get_the_ID());
$cat = $cat->get_primary_term();
$catName = get_cat_name($cat);
$catLink = get_category_link($cat);
echo $catName;
echo $catLink;
add_action( 'template_redirect', 'remove_my_action' );
function remove_my_action(){
global $post;
if(get_post_meta($post->ID, 'meta_key', true) == 'значение') {
remove_action( 'cryout_branding_hook', 'tempera_title_and_description', );
}
}
<?php if ( !empty( $page_title_config['main_title'] ) ):
$class = 'a1';
if(in_category('ID_рубрики')) {
$class = 'a2';
}
?>
<h1 class="<?php echo $class; ?>">
<?php echo wp_kses( $page_title_config['main_title'], $volcanno_theme_config['allowed_html_tags'] ) ?></h1>
<?php endif; ?>
<?php if ( !empty( $page_title_config['main_title'] ) ): ?>
<h1 class="a1">
<?php if(in_category('ID_рубрики')) : ?>
<?php echo wp_kses( $page_title_config['main_title'], $volcanno_theme_config['allowed_html_tags'] ) ?>
<?php else : ?>
<?php the_title(); ?>
<?php endif; ?>
</h1>
<?php endif; ?>
add_action('customize_register', 'dco_customize_register');
function dco_customize_register($wp_customize) {
//FOOTER
$wp_customize->add_section('footer', array(
'title' => 'Подвал',
'priority' => 1,
));
//footer text
$setting_name = 'footer_text';
$wp_customize->add_setting($setting_name, array(
'default' => '',
'sanitize_callback' => 'sanitize_textarea_field',
'transport' => 'postMessage'
));
$wp_customize->add_control($setting_name, array(
'section' => 'footer',
'type' => 'textarea',
'label' => 'Текст в подвале',
));
$wp_customize->selective_refresh->add_partial($setting_name, array(
'selector' => '.footer-desc',
'render_callback' => function() use ($setting_name) {
return nl2br(get_theme_mod($setting_name));
}
));
}
<div class="footer-desc"><?php echo nl2br(get_theme_mod('footer_text')); ?></div>
add_filter( 'display_post_states', 'custom_post_state' );
function custom_post_state( $states ) {
global $post;
$show_custom_state = null !== get_post_meta( $post->ID, '_some_costom_field' );
if ( $show_custom_state ) {
$states[] = __( 'Custom State' );
}
return $states;
}
function my_shortcode_function() {
ob_start();
$parametri = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts' => 1
);
$moi_zapros = null;
$moi_zapros = new WP_Query($parametri);
if ($moi_zapros->have_posts()):
print '<ol>';
while ($moi_zapros->have_posts()) : $moi_zapros->the_post();
$idt=get_the_ID();
$trip=get_post_meta($idt,"trip", true);?>
<li class="map"><a href="<?php the_permalink() ?>" title="Постоянный линк для:<?php the_title_attribute(); ?>" target="_blank"><?php the_title(); if ($trip) {echo " ", $trip, ". День ",get_post_meta($idt,"day", true), ". ";}?> (<?php print get_comments_number();?>)</a></li>
<?php
endwhile;
print '</ol>';
endif;
wp_reset_query();
return ob_get_clean();
}
<?php
/*
Template Name: Full-width layout
Template Post Type: post, page, event
*/
// Page code here...
category-{slug}.php
category-{ID}.php
Почему в Wordpress нет функционала