Default content for a post in one category?

One possibility is this question/answer here by Jan Fabry, which asks for the default content in the process of creating the new post: Force category choice before creating new post? I ended up using a Quicktag as a way of easily getting the content into a post, and because the default content happened to be … Read more

current_cat_ancestor Alternatives

After fumbling around with this for a bit, I realized I needed this to work with custom taxonomies, not just regular categories. I unfortunately couldn’t use “all” of what either the solution I found or Tom did, so I ended up writing my own. As long as you specify a taxonomy arg, you should be … Read more

Extending the site search to include a single custom field

I managed to resolve by extending the query function extend_search( $search, &$wp_query ) { global $wpdb; if ( empty( $search )) return $search; $terms = $wp_query->query_vars[ ‘s’ ]; $exploded = explode( ‘ ‘, $terms ); if( $exploded === FALSE || count( $exploded ) == 0 ) $exploded = array( 0 => $terms ); $search=””; foreach( … Read more

Override a plugin class function

Finally, I figured out how to solve my problem: class Import_Facebook_Events_Facebook_Ext extends Import_Facebook_Events_Facebook { function get_location( $facebook_event ) { if ( !isset( $facebook_event->place->id ) ) { $facebook_event->place->id = ”; //return null; } //other code here return $event_location; } } $new_ife_events = run_import_facebook_events(); $new_ife_events->facebook = new Import_Facebook_Events_Facebook_Ext(); A question: the last two code lines must be … Read more

WordPress Infinite Scroll without using any plugin

For single article infinite scroll below is the solution single.php <div class=”blog-article-section”> <?php while( have_posts() ): ?> <div class=”blog-article”> <?php if( have_posts() ): the_post(); ?> <h2><?php the_title(); ?></h2> <p><?php the_content(); ?></p> <?php endif; ?> <div class=”pagination-single” > <div class=”next_post_link”><?php previous_post_link( ‘%link’,’Previous Post’ ) ?></div> <div class=”previous_post_link”><?php next_post_link( ‘%link’,’Next Post’ ) ?></div> </div> </div> <?php endwhile; … Read more

WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given

I ran into this today. It’s a bug. I filed a bug report here: https://core.trac.wordpress.org/ticket/46797 The problem is this line of code: $qv[‘name’] = trim( $qv[‘name’] ); Source: https://github.com/WordPress/wordpress-develop/blob/a0ca5afd8977b5a3857084d9cb1bd345166e2f21/src/wp-includes/class-wp-query.php#L764 A (malicious) user sends a request that looks like: GET /?q=user/password&name[#post_render][]=passthru&name[#type]=markup&name[#markup]=echo ‘Vuln!! patch it Now!’ > vuln.htm; echo ‘Vuln!!’> sites/default/files/vuln.php; echo ‘Vuln!!’> vuln.php; cd sites/default/files/; echo … Read more

Add new user : make the fields First Name and Last name required

If you were looking to make the fields required in the WordPress admin form for adding new user as i understood from your question, where the output is not filterable, you could basically do what you described (adding form-required) on browser side function se372358_add_required_to_first_name_last_name(string $type) { if ( ‘add-new-user’ === $type ) { ?> <script … Read more