• Как настроить цветовую схему для определенных слов/символов?

    @Pestrich Автор вопроса
    Немного печально. Спасибо за ответ.
  • Как получить JSON-массив с кодом статуса после запроса к БД?

    @Pestrich Автор вопроса
    Спасибо за информацию, я почитал про фильтрацию данных и понял о чем Вы говорили. В своей работе я сделал проверку чтобы количество товаров не было отрицательным, но совсем не подумал о том, что можно вводить различные буквы, не говоря уже о злоумышленниках и все это может привести к последствиям в реальных проектах. Мне нужно больше учиться =)
  • Как получить JSON-массив с кодом статуса после запроса к БД?

    @Pestrich Автор вопроса
    Благодарю за помощь и за указание на мои ошибки.
    Я начинающий, поэтому echo запросы делал для себя, чтобы быть уверенным, что все точно работает или сразу увидеть в чем ошибка.
    А $_GET использую, потому что по условию нужно выводить количество в адресной строке.
  • Как получить JSON-массив с кодом статуса после запроса к БД?

    @Pestrich Автор вопроса
    Убрал все остальные echo, получилось:
    5c3fa04fa9e5e066958015.png
    Правильно?
    Не могли бы вы, пожалуйста, объяснить почему нельзя использовать другие echo перед echo json_encode(), и как теперь вывести это сообщение на экран?
  • Как получить JSON-массив с кодом статуса после запроса к БД?

    @Pestrich Автор вопроса
    Именно команды "echo" нельзя выводить?
    Тогда оставляю фрагмент ниже?
    $arr = array('status code' => 1, 'message' => 'Item added to cart');
    echo json_encode($arr);

    Все верно получилось?
    5c3f9c815aee5292467874.png
    Не понимаю как из этого можно сообщение на экран вывести в виде подсказки.
  • Как сделать AJAX форму добавления товара?

    @Pestrich Автор вопроса
    Хотел посмотреть есть они в get или нет. Может в строку не выводятся. Только начал изучать ajax, пока что плохо понимаю как все работает.
  • Как вывести фотографии из произвольного поля в виде слайдера?

    @Pestrich Автор вопроса
    Благодарю всех за помощь, получилось выводить галерею к каждой записи. Осталось только настроить нужное отображение на сайте. С подключением css и js файлов конечно пришлось помучатся, так как по-началу использовал get_template_directory_uri() вместо get_stylesheet_directory_uri() и получалось что брал url из родительской темы, а не из дочерней.
  • Как вывести фотографии из произвольного поля в виде слайдера?

    @Pestrich Автор вопроса
    Не могли бы Вы подсказать где необходимо подключать файлы для Фоторамы?

    !-- 1. Link to jQuery (1.8 or later), -->
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <!-- 33 KB -->
    
    <!-- fotorama.css & fotorama.js. -->
    <link  href="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.css" rel="stylesheet"> <!-- 3 KB -->
    <script src="http://cdnjs.cloudflare.com/ajax/libs/fotorama/4.6.4/fotorama.js"></script> <!-- 16 KB -->


    На обычной верстке все работает, а вот в WordPress теме не получается. Просмотрел каждый файл, но не нашел похожих строк.
    Использую тему https://github.com/understrap/understrap.
  • Как выводить объекты кастомных типов постов на страницы сайта?

    @Pestrich Автор вопроса
    Попробовал вставить данный код в content.php:
    <?php
    // запрос
    $property = new WP_Query(array(
    	'post_type' => 'property', 
    	'post_status' => 'publish', 
    	'posts_per_page' => -1
    )); 
    ?>
    
    <?php if ( $property->have_posts() ) : ?>
    
    <ul>
    
    	<!-- the loop -->
    	<?php while ( $property->have_posts() ) : $property->the_post(); ?>
    		<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    	<?php endwhile; ?>
    	<!-- end of the loop -->
    
    </ul>
    
    	<?php wp_reset_postdata(); ?>
    
    <?php else : ?>
    	<p><?php _e( 'Извините, нет записей, соответствуюших Вашему запросу.' ); ?></p>
    <?php endif; ?>


    Но так как данный файл подгружается в цикл вывода статей в файле index.php, получается цикл в цикле и все записи будут многократно выводиться на сайт.

    Исходный код index.php:

    <?php
    /**
     * The main template file.
     *
     * This is the most generic template file in a WordPress theme
     * and one of the two required files for a theme (the other being style.css).
     * It is used to display a page when nothing more specific matches a query.
     * E.g., it puts together the home page when no home.php file exists.
     * Learn more: http://codex.wordpress.org/Template_Hierarchy
     *
     * @package understrap
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    get_header();
    
    $container = get_theme_mod( 'understrap_container_type' );
    ?>
    
    <?php if ( is_front_page() && is_home() ) : ?>
    	<?php get_template_part( 'global-templates/hero' ); ?>
    <?php endif; ?>
    
    <div class="wrapper" id="index-wrapper">
    
    	<div class="<?php echo esc_attr( $container ); ?>" id="content" tabindex="-1">
    
    		<div class="row">
    
    			<!-- Do the left sidebar check and opens the primary div -->
    			<?php get_template_part( 'global-templates/left-sidebar-check' ); ?>
    
    			<main class="site-main" id="main">
    
    				<?php if ( have_posts() ) : ?>
    
    					<?php /* Start the Loop */ ?>
    
    					<?php while ( have_posts() ) : the_post(); ?>
    
    						<?php
    
    						/*
    						 * Include the Post-Format-specific template for the content.
    						 * If you want to override this in a child theme, then include a file
    						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    						 */
    						get_template_part( 'loop-templates/content', get_post_format() );
    						?>
    
    					<?php endwhile; ?>
    
    				<?php else : ?>
    
    					<?php get_template_part( 'loop-templates/content', 'none' ); ?>
    
    				<?php endif; ?>
    
    			</main><!-- #main -->
    
    			<!-- The pagination component -->
    			<?php understrap_pagination(); ?>
    
    			<!-- Do the right sidebar check -->
    			<?php get_template_part( 'global-templates/right-sidebar-check' ); ?>
    
    		</div><!-- .row -->
    
    	</div><!-- #content -->
    
    </div><!-- #index-wrapper -->
    
    <?php get_footer(); ?>


    Исходный код content.php:

    <?php
    /**
     * Post rendering content according to caller of get_template_part.
     *
     * @package understrap
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    ?>
    
    <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    
    	<header class="entry-header">
    
    		<?php
    		the_title(
    			sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ),
    			'</a></h2>'
    		);
    		?>
    
    		<?php if ( 'post' == get_post_type() ) : ?>
    
    			<div class="entry-meta">
    				<?php understrap_posted_on(); ?>
    			</div><!-- .entry-meta -->
    
    		<?php endif; ?>
    
    	</header><!-- .entry-header -->
    
    	<?php echo get_the_post_thumbnail( $post->ID, 'large' ); ?>
    
    	<div class="entry-content">
    
    		<?php the_excerpt(); ?>
    
    		<?php
    		wp_link_pages(
    			array(
    				'before' => '<div class="page-links">' . __( 'Pages:', 'understrap' ),
    				'after'  => '</div>',
    			)
    		);
    		?>
    
    	</div><!-- .entry-content -->
    
    	<footer class="entry-footer">
    
    		<?php understrap_entry_footer(); ?>
    
    	</footer><!-- .entry-footer -->
    
    </article><!-- #post-## -->


    Никак не могу понять по какому принципу и в каком именно файле менять код. Уже какие только файлы и код не перепробовал...