<?php
function profile_info_shortcode( $atts ) {
ob_start();
if ( is_user_logged_in() ) {
global $current_user;
if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) && $_POST['action'] == 'update-user' ) {
update_user_meta( $current_user->ID, 'first_name', esc_attr( $_POST['first-name'] ) );
}
?>
<form method="post" id="user_page" action="<?php the_permalink(); ?>">
<label for="first-name"><?php _e( 'Имя', 'ay' ); ?></label>
<input name="first-name" type="text" id="first-name" value="<?php the_author_meta( 'first_name', $current_user->ID ); ?>" />
<input name="updateuser" type="submit" id="updateuser" value="<?php _e( 'Сохранить', 'ay' ); ?>" />
<?php wp_nonce_field( 'update-user' ) ?>
<input name="action" type="hidden" id="action" value="update-user" />
</form>
<?php
}
return ob_get_clean();
}
add_shortcode( 'profile', 'profile_info_shortcode' );
<input class="text-input" name="user_school" type="text" id="user_school" value="<?php the_author_meta( 'user_school', $current_user->ID ); ?>" />
update_user_meta( $current_user->ID, 'user_school', esc_attr( $_POST['user_school'] ) );
$args = array(
'post_type' => 'toys', // cpt
'meta_query' => array(
array(
'key' => 'type',
'value' => 'soft',
),
),
'meta_key' => 'price', // acf field
'orderby' => 'meta_value_num', //or meta_value
'order' => 'DESC'
);
$query = new WP_Query( $args );
// Remove services slug
function remove_slug( $post_link, $post, $leavename ) {
if ( 'services' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'remove_slug', 10, 3 );
// Fix after remove slug
function parse_request( $query ) {
if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
return;
}
if ( ! empty( $query->query['name'] ) ) {
$query->set( 'post_type', array( 'services', 'post' ) );
}
}
add_action( 'pre_get_posts', 'parse_request' );
wp_enqueue_style( 'visit_scripts');
echo do_shortcode(carbon_get_theme_option('crb_form_header'));