First of all include wp-load.php
from WP root installation to those PHP files which you want to display and once you have included to your PHP files then you can use WP functions. You can use is_user_logged_in()
function to check if user is logged in or not.
// Your PHP file that can be viewed only to logged in user
require_once '/path/to/wordpress/wp-load.php';
if ( is_user_logged_in() ) {
// your php file code...
}
And same you can do for HTML by converting them to PHP files and include those above line of code.
Related Posts:
- Running WP Cron on multisite the right way
- Query multiple custom post types in single loop
- Integrating WordPress to my website, while keeping my own authentication system
- Remove/unset options field from backend Settings->General?
- Multisite get_home_url(); – Getting URL for current site
- How to use wp_insert_user on WordPress Multisite?
- Using Cookie Data For WP_Query Loop
- wp_delete_post deletes all posts instead of just expired ones
- Alter secondary loop to exclude posts from current page category
- Display Post co-authored in Author Page
- Sorting Posts | Alphabetical Order
- Looking for most performant way to execute several similar WP queries within shortcodes
- How to query for pages/post depending on slug?
- WordPress custom slug (endpoint) and compare all links
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- wp_query with cat not working
- How to use an associative array in post__in with WP_Query?
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Compare post-IDs within WP_Query? (Less than / Greater than)
- How to use $query->set with post__in?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- WordPress returning 404 for multisite pages
- WordPress, AJAX and pre_get_posts using conditional tags
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Exclude posts based on meta value
- Custom query, checking values of multiple meta keys
- Remove echo from shortcode
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- WP & Server Speed [Teacher Question]
- Redirect to another page using contact form 7? [closed]
- Fatal error: Call to a member function query() on a non-object
- unable to use ‘new WP_Query’ in AJAX call
- Is it best to avoid using $wpdb for security issues?
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- Array to string conversion on array_map
- Target post_date_gmt if it’s empty or not set
- Get all posts as an array ID => Name
- How to hide posts of a specific custom category in WordPress?
- Passing an array into WP_Query as a variable
- Custom query vars filters problem with pagination
- WordPress meta_query >= &
- WordPress WP_Query without query GET parameters
- WordPress homepage setup not working on first load
- Do not duplicate posts with multiple categories in multiple loops
- Displaying Event within two given time frames
- Remove Post if Advanced Custom Field is checked to fix paging
- displaying a fall back query if there’s nothing in the post-type category
- need help adding a new sidebar to a page that can’t use page-templates -> multisite
- How can I fix this code [duplicate]
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- WP_Query: How to get results from both meta_key options?
- How to sort posts by active category in WordPress?
- wordprees multi-site in user panel add filter
- bp-custom.php is not working on a WordPress multisite environment. how to fix it?
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- wp_query with multiple arguments with AND
- Passing in MySQL prepare statement parameter separately throwing error
- Nested Queries of decreasing specificity
- Wrong pagination results, page counter resets when navigating
- How can I update WordPress plugins or WordPress itself in all server?
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Load more posts using AJAX based on posts inside WP_Query
- in_array not working on dev server but works on localhost
- WP query posts BUT show the most recent and one per author
- Define global custom post
- How to select post ID for given parent name with nested prepared queries?
- posts_per_page displays only 2 posts instead of 4 posts
- Internal Server Errors – Moving working multi-site install to my localhost
- Add code to the header of posts by particular author
- Search for single post by 2 tags
- Paged WP_Query is quitting on page 3
- Get Child of Child Pages in custom Menu
- Redirect user role to a specific page on login in a multisite network?
- Meta query not showing result properly
- Woocommerce Related Product by 2 taxonomy
- Remove node from multisites?
- Help on Wp_query to print an term
- Add .php to end of all WordPress Pages (multisite)
- making a search.php query
- List all blogs apart from the current blog and main blog in WordPress Multisite
- Adding users to another blog
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Only Get A Certain Number of Posts From WP_Query
- Create a hierarchical loop at predefined markup requirements
- Querying posts based off a jquery datepicker
- use system script advertising in wordpress multisite
- Use custom get results query to show posts WordPress
- Query seems to be duplicated
- WPMU schedule doesn’t execute actions
- WP Query conflict on tag.php and category.php template
- Force string into signup form
- Keeping the previous get value and add another value when submitted
- Pagination in category.php not functioning
- Display all categories (with link) of custom post type – WordPress
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Three different queries on same page
- How to sort search result by post_title, then by post_content
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress