How to get Tags with specific post id
Put this inside your loop: //Returns All Term Items for “my_term” $term_list = wp_get_post_terms($post->ID, ‘post_tag’, array(“fields” => “all”)); print_r($term_list); Slightly adapted from wp_get_post_terms
Put this inside your loop: //Returns All Term Items for “my_term” $term_list = wp_get_post_terms($post->ID, ‘post_tag’, array(“fields” => “all”)); print_r($term_list); Slightly adapted from wp_get_post_terms
SQL-wise, you only need to join to the wp_posts table once. Joining to the terms stuff will give you multiple rows, so it’s probably easiest to group these and then use GROUP_CONCAT() to flatten the terms into a comma-separated string (updated to use LEFT joins): global $wpdb; $sql = $wpdb->prepare( ‘SELECT p.ID, p.post_title AS Product, … Read more
You can calculate offset via paged and posts_per_page. E.g: $per_page = 6; $paged = get_query_var(‘paged’) ? : 1; $offset = (1 === $paged) ? 0 : (($paged – 1) * $per_page) + (($paged – 1) * 2); $args = array( ‘order’ => ‘ASC’, ‘paged’ => $paged, ‘offset’ => $offset, ‘orderby’ => ‘ID’, ‘post_type’ => ‘post’, … Read more
In XHTML entities are not part of the DTD, and user agents are not required to support them. Exceptions: &, <, >, " and '. To keep WordPress X(HT)ML compatible numeric references are used instead.
one loop with a conditional statement to catch the first post should work; example: <?php if( $wp_query->current_post == 0 && !is_paged() ) : ?> /*the output of the first post*? <?php else : ?> /*the output of all other posts*/ <?php endif; ?>
In functions.php file : function my_recent_post() { global $post; $html = “”; $my_query = new WP_Query( array( ‘post_type’ => ‘post’, ‘posts_per_page’ => 1 )); if( $my_query->have_posts() ) : while( $my_query->have_posts() ) : $my_query->the_post(); $html .= “<h2>” . get_the_title() . “</h2>”; $html .= “<p>” . get_the_excerpt() . “</p>”; $html .= “<a href=\”” . get_permalink() . “\” … Read more
Change the name of news.php to index.php. I don’t know of any legitimate use case that exists for changing index.php. If something else is using index.php then move WP in its own /news directory. You could change the .htaccess but you might run into trouble down the road.
You can achive this using WP Query with meta_query argument as following. $args = array ( ‘post_type’ => array( ‘post’ ), // YOUR POST TYPE ‘meta_query’ => array( array( ‘key’ => ‘country’, ‘value’ => $your_country, // THE COUNTRY TO SEARCH ‘compare’ => ‘LIKE’, // TO SEARCH THIS COUNTRY IN YOUR COMMA SEPERATED STRING ‘type’ => … Read more
WP_Post is a representation of the post as it exists in the database, and the permalink isn’t stored in the database. It’s not stored in the database because it’s not a property of the post. The permalink is determined by the site’s address, its permalink structure, and the post’s slug. Imagine if updating the permalink … Read more