@rennameduser_3432

Не записываются данные в переменную WordPress?

while( have_posts() ) : the_post();
		
		$html = '
			<a href="'.the_permalink().'" class="post-item__photo">
				<img src="'.the_post_thumbnail_url().'" alt="">
			</a>
			<a href="'.the_permalink().'" class="post-item__title">'.the_title().'</a>
			<p></p>
			<a href="'.the_permalink().'" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		';
		$array[] = $html;
		
		
	endwhile;
	print_r($array);


(При этом выводится контент сам, но вот не записывается в переменную, а мне данные нужно передать на фронтенд)

В массиве
spoiler
(
    [0] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [1] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [2] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [3] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [4] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [5] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [6] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [7] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [8] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [9] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
    [10] => 
			<a href="" class="post-item__photo">
				<img src="" alt="">
			</a>
			<a href="" class="post-item__title"></a>
			<p></p>
			<a href="" class="post-item__link">
				<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M42.9546 9.79777V40.4852H32.6078V21.113V18.6988L30.9007 20.4059L8.76622 42.5403L1.41421 35.1883L23.5487 13.0539L25.2558 11.3468H22.8416L3.46936 11.3468L3.46936 1L34.1568 1L42.9546 9.79777Z" stroke="black" stroke-width="2"/></svg> 
			</a>
		
)
  • Вопрос задан
  • 34 просмотра
Решения вопроса 2
@weart
get_permalink
get_the_title

хотя странный вы выбрали способ передачи данных
Ответ написан
artzolin
@artzolin Куратор тега WordPress
php, WordPress разработка сайтов artzolin.ru
И get_the_post_thumbnail_url()
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы