Reinstall WordPress Without Losing Data

I would suggest using Tools -> Export to save your posts and pages. Then you could reinstall your WordPress, upload your theme and Import your content back. This can fix corrupted WordPress core or theme files but you would have to setup your theme options and settings again.

Prevent access to custom login page for logged in users

You should redirect as early as possible. The best hook for this is template_redirect. Check for 2 conditions – if the page is ‘login’ and user is logged in: function redirect_login_page() { if( is_page( ‘login’ ) && is_user_logged_in() ) { wp_redirect( home_url() ); exit; } } add_action( ‘template_redirect’, ‘redirect_login_page’ );

Setting up Different Layouts for Each Product Category and Subcategory [closed]

Woocommerce follows WordPress’s native template hierarchy system. To create a template file to be used for a specific category, use this file naming scheme: taxonomy-{taxonomy}-{term}.php So, for Woocomerce categories, this will be: taxonomy-product_cat-{category_name}.php You can create one of those files for each category that you want to have a different appearance from the default category. … Read more

Creating user relationships

WordPress does provide you with the ability to save meta data for users, so you could just store the agent’s user id in a meta field of his subscribers, like update_user_meta( $user_id, “agent”, $agent_id ). You can then query those users with the WP_User_Query’s meta_query, e.g. $agents_subscribers = new WP_User_Query( array( ‘meta_key’ => ‘agent’, ‘meta_value’ … Read more

How to implement a custom password field that redirects to another page upon correct password?

The problem is that WP will redirect to the referrer when the authentication succeeds. Fortunately, you can also supply _wp_http_referer and it will be preferred over the HTTP Referrer, so we need to add a hidden field to the form and fill it with the permalink of the post in question: echo str_replace(‘</form>’, ‘<input type=”hidden” … Read more

Cannot figure out how to center div in WordPress theme [closed]

As mentioned in my comment, http://howtocenterincss.com/ is a great resource to get the necessary CSS to horizontally or vertically center containers or paragraphs in CSS. Since you mentioned the text should be centered, the wbesite would give you this solution: <div style=”text-align:center;”>Text Content</div> If you want to center a container instead, margin-right: auto; margin-left: auto; … Read more

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