jgraup
  • Member for 6 years, 1 month
  • Last seen more than a month ago
WP Cli - post add meta in xargs after wp post generate - add multiple fields
Accepted answer
1 votes

You just need to change the syntax of xargs to run multiple commands using the same placeholder: wp post generate --format=ids --count=10 | sed -e "s/ /\n/g" | xargs -n1 -I % sh -c 'echo "Adding ...

View answer
add button to post edit page when post_status=publish
5 votes

Thanks userabuser for the head start. I believe the expanded code would look closer to: add_action( 'post_submitbox_misc_actions', 'custom_button', 10, 1 ); function custom_button( $post ) { // ...

View answer
Dynamically redirect page based on URL?
1 votes

Assuming you stick with add_rewrite_rule(), if language and title where set as meta data on the /en/ post, then you can simplify the search down to a simple WP_Meta_Query() for /:lang/:title/ and pull ...

View answer
Capture and display users name
0 votes

Use wp_get_current_user to get the current user (if any) then check or update the display name - update_user_meta or wp_update_user. When you have a user, you'll probably want to set a flag on the ...

View answer
Custom rewrite rule not working
0 votes

There are a lot of assumptions here but maybe you can clear those up. This assumes you made a CPT that could look like: domain.com/page/class/english-pro And converts it to domain.com/page/class-...

View answer
How do i upload an image and return the image id?
Accepted answer
1 votes

Take a look at side loading images. media_sideload_image()/wp_handle_sideload() and get the ID from the URL. attachment_url_to_postid. <?php $url = "http://wordpress.org/about/images/logos/...

View answer
Add comma between variables
Accepted answer
2 votes

You don't concatenate these outputs. The_field will print while get_field can be used to concat. <?php the_field('fl_venue'); echo ', '; the_field('fl_address'); ?>

View answer
Fastest way to update a theme
Accepted answer
0 votes

So Mark Kaplun had it correctly, GIT is a great way to update a theme on the server. Not just for updating but also for versioning. The trick really is to eliminate any barrier outside your normal ...

View answer
Limit scripts and styles on dashboard for user role
Accepted answer
1 votes

Install Query Monitor to check which scripts and what hook they are using for your role. Keep in mind these scripts may have dependencies. You should probably start with the Dashboard Widgets API. ...

View answer
Check if page is embeded
Accepted answer
2 votes

The server doesn't know what the client is doing with the output and as such, you're limited in what you can assume. You may or may not have params sent in the request, referer, current uri and ...

View answer
WordPress Object Oriented plugin development
Accepted answer
1 votes

A few things stand out. Don't load all your classes and files up front. Load admin class when admin_init hooks fire and front-end classes when front-end hooks fire. Just think about lazy loading ...

View answer
Export and overwrite pages on import?
1 votes

You have a narrow selection to choose from. Either replace the database tables with something like wp-cli or have a special import-export process for your data. If you want to make this granular, you ...

View answer
Using nonce when loading posts with AJAX
Accepted answer
1 votes

GET puts all your params on the URL like; http://example.com/thing?foo=bar&x=y For POST you could include all that information but it won't show in the URL. http://example.com/thing Obviously ...

View answer
Send email once every 12 months to a particular user
Accepted answer
2 votes

Set update_user_meta() for a WP_User if get_user_meta() ends up empty. Update a key with a future date for the next year: $startDate=date('Y-m-d'); $futureDate=date('Y-m-d', strtotime('+1 year', ...

View answer
Importing URLs of Audio Enclosures
0 votes

It's hard to tell what you're working with from the image, but I'll assume newline breaks. <?php $string = "http://www.podcast.com/track.mp3 2207703 audio/mpeg"; echo "<pre>"; echo $string;...

View answer
How to set value in Query Loop?
Accepted answer
0 votes

You can run multiple nested WP_Queries as long as you reset_postdata() to get the outer loop back on track. $query_args = array ( 'posts_per_page' => '1', 'meta_key' => $...

View answer
What are WordPress admin supported browsers?
0 votes

Supported browsers will change with the each release and theme you have installed. You might want to check the release notes or issues on trac to find any incompatibilities. The best I could find was ...

View answer
Hang Up Followed By Can’t select database
Accepted answer
0 votes

Try a plugin like Query Monitor to see if there are queries or things you can identify quickly. A DB may need a log rotated or you could have some DEBUG process turned on that is logging. Backups ...

View answer
how to get permalink
1 votes

To get a permalink you need to use get_permalink(). Just pass the ID of the post or leave it blank to get the current page in the Loop. wp_localize_script () will render PHP variables on the page ...

View answer
How to show/hide php table rows based on the content of custom fields
Accepted answer
2 votes

You just need to render each section a little more efficiently. Making it look nice with all the fancy spacing won't pay off when a computer is reading the code (see tab v. space). So for the '...

View answer
Preventing form resubmission on contact form plugin
0 votes

You can setup a wp_nonce_field to act as a single use token. You can then wp_verify_nonce to make sure the action requested matches the token. A more ideal way is to just use an AJAX solution and ...

View answer
If I define a variable in header.php, how do I make it available to templates?
1 votes

Don't muddy up the $_GLOBAL space. If you want to nix the class route and use a function with a statically scoped variable you can keep it contained. // getter + setter function function ...

View answer
Trying to remove white space between nav bar and content?
Accepted answer
0 votes

This is a CSS issue. Adding this to the bottom of your page will help. <style> body main#primary { background: #fff; padding-top: 10px; } main#primary .wrapper { ...

View answer
Trim excerpt to first paragraph
Accepted answer
0 votes

You can match this with regEx and easily choose the amount of paragraphs to return. // in context function triangle_x_excerpt( $text, $raw_excerpt ) { $content = apply_filters( 'the_content', ...

View answer
Last query_var not working with rewritten URL
Accepted answer
0 votes

[] = not [] .= to append to an array. function custom_query_vars_filter($vars) { $vars[] = 'ae_issues'; $vars[] = 'issueloc'; $vars[] = 'issuearea'; return $vars; } Another trick, if you don'...

View answer
Append taxonomy terms as class names in markup?
Accepted answer
3 votes

Differ the output until you have a collection ready. $terms = get_the_terms( $post->ID, 'teams' ); // create a collection with your default item $classes = array('person'); foreach ($terms as $...

View answer
adding google analytics via echo or between <php> tags
Accepted answer
0 votes

As long as you're quotes are escaped to render the final code correctly, you should be fine either way. That just a matter of preference. If you go with the first route, you'll be able to migrate ...

View answer
How to schedule and publish a post after it's ready?
0 votes

Use wp_publish_post( $post_id) to change the post's status. And consider another hook like 'save_post' instead of 'publish_post' to kick off the process.

View answer
Custom post status
0 votes

Have you read Custom Status on codex.wordpress.org/Post_Status? NOTICE: This function does NOT add the registered post status to the admin panel. This functionality is pending future development. ...

View answer
Setting Up PHP Workflow in Wordpress
Accepted answer
1 votes

Having a local environment that is the same for all devs is pretty easy to setup using vccw.cc or basic-wordpress-vagrant. Use Git for plugins and themes -- each as their own repo. Free private ...

View answer
1
2 3 4 5
13