WordPress – thumbnail image from youtube (function and loop)

Well, assuming the post content will be provided by Youtube embedded code, a change in the regular expression is needed. The function must obtain the source of the iframe. So would be as follows: function get_thumbnail_fromyoutube( $size = 0 ) { global $post, $posts; $youtube=””; $get_url = preg_match_all(‘/src=”https://wordpress.stackexchange.com/questions/151570/([^”]+)”https://wordpress.stackexchange.com/”, $post->post_content, $matches); $youtube = $matches[1][0]; var_dump($youtube); if(preg_match(‘/^(http:\/\/www.youtube.com)/’, … Read more

Post Loop not Returning Permalink

You have made the mistake in getting the post link in your code. Missing <?php global $post; ?> – Initialization at the start of the loop After setting up the post data your query becomes like normal Wp_Query so that you can get the permalink() in normal method itself using the_permalink() instead of get_permalink($post->id). Since … Read more

Query post types with multiple keys

meta_query has a relation parameter just like tax_query so: $documents = array( ‘post_type’ => ‘documents’, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘document-type’, ‘value’ => ‘manual’, ), array( ‘key’ => ‘document-status’, ‘value’ => ‘current’, ) ) ); query_posts( $documents ); get_template_part( ‘loop’, ‘documents’ ); wp_reset_query();

Replace query_posts with pre_get_posts

Without seeing the broken code it is hard to say, but your filter should look something like this: function pregp_wpse_97354($qry) { if (is_front_page() && is_main_query() && is_user_logged_in()) { $qry->set(‘cat’,2); $qry->set(‘posts_per_page’,5); $qry->set(‘orderby’,’date’); $qry->set(‘order’,’DESC’); } } add_action(‘pre_get_posts’,’pregp_wpse_97354′); You mentioned something about the user being logged in, which your code does not check for, but I threw that … Read more

Problem with query_posts for a custom taxonomy in theme options

I see three things. if ( function_exists( ‘of_get_option’ ) ) : query_posts( ‘cat=” . $homepage_feature = of_get_option( “homepage_feature’ ) . ‘&posts_per_page=3’ ); You have a syntax error. There is no endif;. Maybe that is a typo, but maybe not. If you are trying to write a one-line if, remove the colon. Your title states “custom … Read more

Only display posts with comments

I ran into this same problem recently and developed a good solution that maintains paging (which some of the answers here do not) and also allows for only targeting certain comment types and comment approved statuses. function has_comments_join( $join, &$wp_query ) { global $wpdb; if ($comment_term = $wp_query->get(‘post_has_comments’)) { $join .= $wpdb->prepare(” JOIN $wpdb->comments ON … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)