The is_front_page()
function calls wp_query::is_front_page()
. If you scroll down to look at the source, you will see the code you’re looking to trigger:
elseif ( 'page' == get_option( 'show_on_front') && get_option( 'page_on_front' ) && $this->is_page( get_option( 'page_on_front' ) ) )
return true;
To meet that condition, you’ll just need to do this in the code to set up for the test:
update_option( 'show_on_front', 'page' );
update_option( 'page_on_front', $post_id );
Related Posts:
- WordPress Themes and PHP unit
- Why Can’t PHPUnit UnitTest My WordPress Website
- Setting Up PHPUnit tests for WP development on Windows
- Unit Test in WordPress
- WordPress and WordPress-test-lib not getting added to tmp folder
- How do I make a redirect in PHP?
- Include files in functions.php
- Retrieve POST data from AJAX call
- urlencoding of the_title() doesn’t work?
- Alter query on edit.php
- Check if widget has content
- Displaying post per day
- Php string not working in WordPress Functions.php [duplicate]
- Why isn’t my if/elseif/else working correctly here?
- How to use SRCSET with get_the_post_thumbnail()?
- Why is PHP Cookie via plugin only set when logged in as Admin and not regular users? and other questions
- Insert After Second Paragraph Without Tag?
- if statement on database query
- Question about the template-loader.php file
- WordPress-site can be reached on x.x.x.x/index.php – but not directly on the IP without index.php
- Using wp_get_image_editor in a standalone script
- Is it possible to move wordpress out of webroot?
- the_author() not working outside the loop
- page template for attachement page?
- Styling images coming from another blog
- PHP If user is logged in & on home page redirect
- PHP Deprecated: WP_RSSjb has a deprecated constructor
- Ajax $wpdb not returning table data
- IMG src weird behaviour inside a single post loop
- Set WordPress Default Template
- stats_get_csv (WordPress Stats) to only display top posts (not pages)
- woocommerce subscriptions – get expiration date [closed]
- Using WordPress gettext functions in a library outside plugin or theme scope
- Showing content from one page on another
- How to insert a single row to WP database table?
- Get date numerical and separate?
- How to iterate within Magic Fields Group foreach loop? [closed]
- How can I randomize a Nextgen Gallery Slideshow [closed]
- Where to put snarfer.php?
- How to check if a meta value has already been assigned to any user?
- WooCommerce custom product dimensions
- I restricted wordpress by logged users. It’s possible exclude a page?
- Display an image if odd number of posts in grid
- HTML escaping data with ajax requests
- Custom ajax call returns 0 [duplicate]
- Metabox Not saving data
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Timthumb.php image gallery not working on Multisite WordPress
- How to use wordpress function wp_enqueue_script() in php?
- Parse error: syntax error, unexpected ‘,’
- Use get() method to grab all categories and output inside another method
- Create a package of products as one Item in woocommerce?
- How to set cookies
- How can I split my query result in 2 arrays?
- Add a custom class to the body tag using custom fields
- how to edit a specific post slug using a php code?
- Display the video of a post_format Video
- Manually Create PHP Page For A Redirect
- How do I check if there is a tag in the title
- GravityForms Limit Submission Per Time Period by User or IP by 30 minutes?
- Get All In One SEO Pack to use custom field instead of Content
- php loading different structure than source code
- Truncate title to single line & container width
- Submit form to db
- WordPress Rewrite Rule
- How do I attach an invoice PDF to an email in the Dukapress plugin for WordPress?
- Programmatically revert to backup .htaccess a possibility?
- Prevent post from being published and show error
- WordPress User Meta value variable into Google Gauge Chart
- Problems updating nested ACF field groups
- couldnt show short code atts in category
- “WARNING: Found @$ in the file __ Possible error suppression is being used
- Submiting with problems on one of the options php wprdpress
- Embed video from streamtape using direct link
- Changing ALT-tag for logo in wordpress
- str_replace remove words from title
- Woocommerce checkout page – custom field checkbox value into email
- How to print all the inline styles in the WP_Styles instance together with their keys?
- Create form which redirects to site in network?
- Custom Plugin Develoment, Form Action
- Theme editing “post thumbnail” help
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- AJAX Returning Way Too Many Posts
- WordPress AJAX load post metadata in modal
- Add point on excerpt post
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Give permission to admin to see user’s page
- add shortcode heading showing multiple time
- List of child pages fetch next results at link click
- Limit ads appearing more than three times
- How does add_action ‘comment_post’ work?
- Showing Subcategory’s Name and Link Instead of Parent Category’s
- reorder a WP_Query, using a dropdown
- Convert ACF checkbox choices to links [closed]
- How to modify this function to exclude also the post belonging to a specific category?
- Custom taxonomy with page post type – WordPress
- Alternative to php echo within code
- Why does WordPress not send the user the email to add a password?
- How to put a class in the p tag automatically added by the_content() in the wordpress loop?