Show posts based on user preference in wordpress

This is an interesting snippet that will help you to set a preference for the users, so that they will choose their favorite categories and they will see posts from these categories only. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters Show hidden characters <?php add_action( 'show_user_profile', 'extra_fields' ); add_action( 'edit_user_profile', 'extra_fields' ); add_action( 'personal_options_update', 'save_fields' ); add_action( 'edit_user_profile_update', 'save_fields' ); add_action( 'pre_get_posts', 'exclude_category' ); function extra_fields($user) { $pref_cat = explode( ',', […]

Continue Reading

You may also like