Get posts and include taxonomy term

You should be using get_the_terms(). wp_get_post_terms() queries the db to get post term info, where as get_the_terms() returns the post term objects directly from the post term cache and only queries the db if that info is not available. By default, all post’s terms are cached by the query being executed. EDIT I cannot comment … Read more

store posts_id of category into a varable?

For getting the posts related to each category you need to use get_posts( $args ) function and in $args you can add your category_id $args = array ( ‘post_type’ => ‘post’, ‘category’ => $cat_ID, ‘post_status’ => ‘publish’, ); $my_posts = get_posts( $args ); // return array of posts // storing all post ID in an … Read more

Wrap every month posts in div

$last_month = null; while ( $the_query->have_posts() ) : $the_query->the_post(); $the_month = get_the_time( ‘Ym’ ); // e.g. 201611 if ( $last_month !== $the_month ) { if ( $last_month !== null ) { // Close previously opened <div class=”row” /> echo ‘</div>’; } echo ‘<div class=”row”>’; } $last_month = $the_month; ?> <div class=”col-3″> <?php the_title(); ?> </div> … Read more

Displaying posts that belong to a specific author

After setting a taxonomy/post_type you firstly need to flush the rewrite rules. To achieve this you could either run $ wp rewrite flush if you have installed the wp-cli or go to “Settings->Permalinks” and save once. To list a taxonomy in the frontend the url would be example.com/author-team/tom. You could also access the taxonomy url … Read more

Linking to pages/posts within the site

WordPress always uses the full URL when it inserts a link. There are a number of reasons for this, and they are all good reasons. You can add relative URLs yourself by simply typing your own links and omitting the domain portion of the link. So http://sitename.tld/cool-page becomes /cool-page. As I said, though, this is … Read more