if I create ‘front-page.php’, then how do I link to post index?

Since WordPress 4.5 you can use get_post_type_archive_link( ‘post’ ) to link to the page containing the blog posts. Depending on what you’ve set under Settings -> Reading, this will be either the front page, e.g. example.com/ or a specific page like example.com/news/. home_url( “https://wordpress.stackexchange.com/” ) always points to the front page.

Get taxonomy terms only of the WP_Query current posts

You’d probably do something like this $args = array( ‘post_type’ => ‘product’, ‘product_cat’ => get_queried_object() ); $query = new WP_Query( $args ); $termsInPosts = array(); if ( $query->have_posts() ) { while( $query->have_posts() ) : $query->the_post(); $postTerms = wp_get_post_terms(get_the_ID(), ‘brands’, array(‘fields’ => ‘term_id’)); foreach ($postTerms as $postTerm) if (!in_array($postTerm->term_id, $termsInPosts)) $termsInPosts[] = $postTerm->term_id; endwhile; } $marcas_terms … Read more

WP_Query is printing out only one post when posts_per_page is set to multiple

you are re-initializing the out variable that is why it shows only one product // Custom Post Type for Use Cases page slider function create_post_type() { register_post_type( ‘use_cases’, array( ‘labels’ => array( ‘name’ => __( ‘Use Cases’ ), ‘singular_name’ => __( ‘Use_Case’ ) ), ‘public’ => true, ‘has_archive’ => true, ) ); } add_action( ‘init’, … Read more

wp_query ‘s’ parameter does not work with custom post type

You can do like this, $args = array( ‘post_type’ => ‘tribe_events’, ‘post_per_page’ => get_option(‘posts_per_page’), ‘s’ => get_search_query() ); $query = new WP_Query($args); // Use new keyword and you need to use WP_Query not Wp_Query while($query->have_posts()): $query->the_post(); the_title(); endwhile;wp_reset_postdata(); I used this in search.php file. Worked without any problem.

Display posts from #6 to #20 on archive page

Add offset in the query and give value as 5 so, the first 5 will be skipped. Below is code snippet for the same $custom_args = array(‘post_type’ => ‘your custom post type name’, ‘posts_per_page’ => ’20’, ‘orderby’ => ‘id’, ‘offset’=>5, ‘order’ => ‘ASC’,); $custom_query = get_posts($custom_args); foreach ($custom_query as $value) { //your data }

How can I remove “”

The default Shortcode will add that markup when necessary and only if the active WordPress theme didn’t enable HTML5 support for the gallery Shortcode’s markup/output. Or, in rare cases, a plugin or a custom code may have disabled the support. So an easy way to get rid of that <br> tags, is by enabling HTML5 … Read more

Checking is user author of number of posts?

I guess count_user_posts is what you’re looking for 😉 This is how you use it: $user_post_count = count_user_posts( $userid , $post_type ); And it returns the number of published posts the user has written in this post type. PS. And if you want some more advanced count, get_posts_by_author_sql can come quite handy.

Show Two custom Post type and their posts on category page

First, I would recommend making this change in Category.php file, as archive.php is affecting tags as well as other archives according to WordPress Theme Hierarchy file system. Try adding the two queries like next: $cats = get_the_category(); $cat_id = $cats[0]->term_id; // news $args = array( ‘post_type’ => ‘news’, ‘posts_per_page’ => 5, ‘cat’ => $cat_id, ); … Read more