foreach all the post

Your code has many errors:- $thumbs isn’t used anywhere. $img_url = $thumb[‘url’]; undefined variable if(is_array($thumb) && $img_url) always false because of second point. $search_data = []; should be outside of loop. Check the correct part of code $search_data = []; if($query->have_posts()): while($query->have_posts()): $query->the_post(); $img_url = get_the_post_thumbnail_url(); if(!empty($img_url)){ $search_data[] = array( ‘name’ => get_the_title(), ‘thumb’ => … Read more

How to insert current “login” page to certain page?

I am not completely sure what you mean, but it looks like you are looking for is_user_logged_in. You can use this test in your templates to test if a user is logged in and display information accordingly. In this fassion: if (is_user_logged_in()) { … show some content … } else { echo “Please, login first”; … Read more

How to string lines from the_content() hook in WordPress?

I don’t know any other way There is a much, much better way to do this – custom fields. As per these instructions in the custom fields docs, let’s say you use the field name iframe_url: <iframe src=”https://wordpress.stackexchange.com/questions/230707/<?php echo esc_url( get_post_meta( $post->ID,”iframe_url’, true ) ?>” width=”960″ height=”540″ frameborder=”0″ allowfullscreen=”allowfullscreen”></iframe> <?php the_content() ?> See how much … Read more

display php code in header using wp_head()

As per my understanding you wish to print content from get_option below . For that please write below code to funcitons.php file: function my_facebook_tags() { return $options = get_option(“p2h_theme_options”); } And below code within your header file below to wp_head() write: <?php echo my_facebook_tags();?> Hope this will resolve the issue for you! EDITED: Try the … Read more

Change body_class() PAGE to HOME

Solved with: <?php add_filter( ‘body_class’, ‘alter_body_class’, 20, 2 ); function alter_body_class( $classes ) { foreach( $classes as $key => $value ) { if ( $value === ‘page’ ) { unset( $classes[ $key ] ); } } return array_merge( $classes, array( ‘home’ ) ); } ?>