Override global query results without hooks

It is quite hard to understand what you need to do here, but you need to look at the following Do not use the global variables as local variables, it breaks the global variables and causes issues with the loop. It is also quite hard to debug when you run into issues. The only global … Read more

JS Support Ticket – Auto create WP account

wp_create_user is your friend! It takes a username, password, and email: wp_create_user( $username, $password, $email ); And here’s an example: $user_id = username_exists( $user_name ); if ( !$user_id and email_exists($user_email) == false ) { $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false ); $user_id = wp_create_user( $user_name, $random_password, $user_email ); } else { $random_password = __(‘User already exists. … Read more

Missing Argument

You didn’t specify how many arguments your function accepts when you used add_filter: add_filter( $tag, $function_to_add, $priority, $accepted_args ); Your code only passes a $tag and a $function_to_add, but it doesn’t tell WordPress what priority it should be, or how many accepted arguments your function takes. You need to fix that. If you don’t provide … Read more

single-{cpt}.php ignored

Any template file must be in the current active theme folder. If they are in a different location, they won’t be automatically loaded, instead you need to code and modify the template file location determined by WordPress template system: add_filter( ‘template_include’, ‘envento_type_templates’, 99 ); function portfolio_page_template( $template ) { if ( is_archive( ‘evento_type’ ) ) … Read more

Why get_posts() not returning only selected category posts from Custom Post Type?

First, your custom post type is portfolio-item, not portfolio_item. Note that you register the post type with $this->base name and previously you did $this->base=”portfolio-item”;. Also, numberposts is obsolete, use post_per_page instead: $args = array( // ‘post_type’ => ‘portfolio_item’, ‘post_type’ => ‘portfolio-item’, ‘orderby’ => ‘rand’, ‘post_per_page’ => 1 ); Then, the taxomy argument of your query … Read more