How to set up a private custom post type that is accessible in the administrative dashboard?

For the frontend, you can use template_redirect action to identify the page, and perform redirects or adjust the request on the fly (untested): add_action( ‘template_redirect’, static function () { if ( ! is_singular( ‘cpt’ ) && ! is_post_type_archive( ‘cpt’ ) ) { return; } if ( current_user_can( ‘read_private_pages’ ) || current_user_can( ‘read_private_posts’ ) ) { … Read more

Search for portfolio tags & mixing portfoliotags and post tags

It sounds like you’re encountering several issues with customizing search and tag functionalities in WordPress, particularly concerning portfolio and blog posts. Let’s tackle each point step by step. Filtering Search Results to Include Only Posts and Portfolio Posts Your initial function in functions.php is almost correct, but it seems to be improperly filtering the post … Read more

When to use WP_query(), query_posts() and pre_get_posts

You are right to say: Never use query_posts anymore pre_get_posts pre_get_posts is a filter, for altering any query. It is most often used to alter only the ‘main query’: add_action(‘pre_get_posts’,’wpse50761_alter_query’); function wpse50761_alter_query($query){ if( $query->is_main_query() ){ //Do something to main query } } (I would also check that is_admin() returns false – though this may be … Read more

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