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:
- How to use wp_insert_user on WordPress Multisite?
- WP_Query | Help me create a search term with an ‘OR’ relation?
- Why does “get_option” pull in the older value in options.php, rather than the newer value, on submission of a form?
- How can i get the last post from wp multisite?
- WP_Query use for a filter with multiple Taxonomies and Terms
- Display Post co-authored in Author Page
- Display related products with custom output
- How do I dynamically generate args for wp_query?
- Looking for most performant way to execute several similar WP queries within shortcodes
- Get Current User Id Inside a Loop Returns 0 For a Shortcode
- Custom page archive query by url var calling page twice on one of my custom queries?
- How to add values to media “whitelist_options” in wp-admin/options.php template?
- How to query for posts with a null or blank post_name?
- WordPress pagination not working with search page
- WP Query with custom Shortcode
- How to use an associative array in post__in with WP_Query?
- Add more button if more 8 items
- WordPress returns “The link you followed has expired” error page whenever I add a new site, add a user etc
- WordPress, AJAX and pre_get_posts using conditional tags
- Exclude posts based on meta value
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- 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
- WordPress theme options error
- Moving code from theme header to functions.php
- WP_Query fails despite having 1 post
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- How do I display offsite database info on my wordpress site?
- Timthumb.php image gallery not working on Multisite WordPress
- Why doesn’t PhotoSmash plugin play well with wp_query?
- the_posts_pagination() not working in wpquery
- Find Site ID From WP_Post
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- List all blogs, but exclude the main site
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- Custom route and query
- change the default order of posts only for specific categories
- Getting posts to exclude from array
- Custom post type permalinks do not appear using the link functions
- How can I split my query result in 2 arrays?
- array_rand not working correctly?
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- How do I check if there is a tag in the title
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- How to extract information from a wp_query result?
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- orderby meta_value_num is not working, giving default order
- How can I modify this code to make the search box include tags and meta
- WordPress Multisite login_redirect to primary blog and specific page based on role
- WP_Query for woocommerce products with a pattern as a post_title
- WordPress Search Ajax + Isotope + InfiniteScroll
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- How to call my PHP function with AJAX ? wp_query
- Ajax filter with loadmore button
- Query by pagename not Working
- Delete post meta by serialized meta value
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Getting info about selected posts using one WP_Query
- Annoying/confusing WordPress memory limit exhausted
- Create form which redirects to site in network?
- WP_Query To Display Product Of Brand On Taxonomy Page
- How to display last whole post on the homepage
- How to return count of items found in SQL query
- wp_query beginner
- SQL Query Search page
- For each 3 posts, show a different post type
- Importing demo data in Multisite
- insert thumbnail image from php script
- Masonry layout within the loop
- Weird Behaviour: Not all WordPress Posts appearing
- Query category-specific, paginated posts and allow viewer to change sort order
- wordpress is_main_query() breaks
- allow previews outside wordpress folder (Outsourcing WP previews)
- Advanced Taxonomy query, with 3 post types
- Custom PHP-coding in MU installs
- Why does a meta_query break this WP_Query?
- I need a button to appear when not loged in and another when logged in, I need help fixing code PLEASE!
- WPMU – How to echo only one URL
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- Three different queries on same page
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to show correct td of table tags in wp_query loop
- Single wordpress multi website down need help factoring what it is
- Enabling pretty permalinks with Docker, Multisite WordPress and Caddy
- Running WP-Cron on Multisite networks the right way?
- External WP_Query call from PHP crashed after version update
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- Set custom post type to load custom block pattern by default
- WordPress query_posts with multiple tax_query
- Filtering with Attributes – how to display all non-queried products below query
- WordPress Query with meta_key and order by another meta_key