How to force a query conditional?

Did you check what part of is_front_page() is causing it to return false? I could reproduce the problem by following the setup from the trac ticket. In my case inside this function the call to is_page() was returning false. I guess this is due to using $wp_query->set() for page_id and is_page is only causing the … Read more

Display List Of Posts Containing a Relationship Field Value [ACF]

I am updating my complete answer based on your clarification in the comment below. I hope this helps: <div class=”entry-content”> <h2>Documents written by this writer</h2> <?php /* * Query posts for a relationship value. * This method uses the meta_query LIKE to match the string “123” to the database value a:1:{i:0;s:3:”123″;} (serialized array) */ $documents … Read more

Get current post id in functions.php

If you hook your localize script function to wp_enqueue_scripts, then you will have access to the global $post variable. As long as you pick a hook at or after ‘wp’ you should have access to the global $post. <?php add_action(‘wp_enqueue_scripts’, ‘YOUR_NAME_scripts’); function YOUR_NAME_scripts() { wp_enqueue_script(‘YOUR_NAME-js’); global $post; $params = array( ‘site_url’ => site_url(), ‘admin_ajax_url’ => … Read more

Adding additional data to WP_Post object

If your extra data directly references a post meta you don’t have to do anything, because WP_Post implements the »magic« methods __isset() and __get() which directly asks for post meta keys (except for the following four keys: page_template, post_category, tags_input and ancestors). Here’s a quick example that shows the behavior: <?php $post_id = 42; $meta_key … Read more

How to remove_query_arg() for paginate_links()

Not sure if you mean this kind of approach: add_filter( ‘paginate_links’, function( $link ) { return filter_input( INPUT_GET, ‘from_expired’ ) ? remove_query_arg( ‘from_expired’, $link ) : $link; } ); to remove the from_expired from the pagination links if it’s in the current GET query.

tech