get_posts()
, и в цикле обновляете с помощью wp_update_post()
, т.е. передаете ей $post_id и 'post_type' => 'page'$custom_value
передаете новое значение для ссылки. Измененный текст у вас по прежнему в переменной $html$html = file_get_html($file_path);
// получаем ссылку
$link = $html->find( 'a.like', 0 );
$link->href = $custom_value;
$html->clear();
unset($html);
$html = file_get_html($file_path);
// получаем ссылку
$link = $html->find( 'a.some-class', 0 )->href;
$html->clear();
unset($html);
current_user_can( 'manage_options' )
, чтобы этот текст мог видеть тот, кто имеет права администратораfunction goods_value() {
if ( current_user_can( 'manage_options' ) ) {
echo '<p>Стоимость товаров на этой странице: ' . $p . '</p>';
echo '<p>Стоимость товаров в категории: ' . $c . '</p>';
echo '<p>Стоимость всех товаров на сайте: ' . $s . '</p>';
}
}
if ( file_exists( $file_path ) ) {
$html = file_get_html($file_path);
// получаем r-attr
$r_attr_text = $html->find( '.r-attr a', 0 )->plaintext;
$r_attr_link = $html->find( '.r-attr a', 0 )->href;
// получаем ссылки на изображения
$images = $html->find( '#msgood-gallery img' );
foreach ( $images as $key => $image ) {
$link = $image->src;
}
$html->clear();
unset($html);
}
$query = new WP_Query( [ 'post_type' => 'post' ] );
while ( $query->have_posts() ) {
$query->the_post();
// проверяем заголовок на пустоту
if ( get_the_title() == '' ) {
var_dump(get_the_ID()); // печатаем ID
}
}
$meta_query = array(
'relation' => 'OR', // не обязательно, по умолчанию 'AND'
array(
'key' => 'key_name',
'value' => 'значение поля',
'compare' => '=' // не обязательно, по умолчанию '=' или 'IN' (если value массив)
)
);
get_terms()
$terms = get_terms( array(
'taxonomy' => array( 'post_tag', 'my_tax' ),
'meta_query' => $meta_query,
) );
foreach( $terms as $term ){
print_r($term);
}