jgraup
  • Member for 6 years, 2 months
  • Last seen more than a month ago
Remove JSON API links in header html
Accepted answer
39 votes

I see in filters.php "add_action( 'wp_head', 'rest_output_link_wp_head', 10, 0 )" Which makes me think this should do the trick to remove rel='https://api.w.org/'. remove_action( 'wp_head', '...

View answer
How to remove rest api link: in http headers?
Accepted answer
17 votes

The output is generated by the rest_output_link_header(). This function is used in two actions, wp_head and template_redirect in default-filters.php:@line234. You can remove the function from those ...

View answer
Need a simple but complete example of adding metabox to taxonomy
Accepted answer
16 votes

This will add a field called 'TERM META TEXT' to your categories. I did take out the nonce but I really think it should go back in. Also, it's just better to have some sanitization vs. none. This ...

View answer
Running WP Cron on multisite the right way
15 votes

After you've added the constant in wp-config.php defined('DISABLE_WP_CRON') or define('DISABLE_WP_CRON', true); WP-CLI And assuming you have your config.yml setup correctly, you can ommit the --...

View answer
Link to Download Latest WordPress PLUGIN Version
Accepted answer
13 votes

https://downloads.wordpress.org/plugin/{plugin-name}.latest-stable.zip The structure should be the same for all WordPress.org plugins and the link you're looking for is: https://downloads.wordpress....

View answer
How do I add a WP_List_Table to WordPress page?
Accepted answer
11 votes

Your WP_List_Table will be different -- this was adapted from WP_List_Table – a step by step guide and using the GIST: Sample plugin for usage of WP_List_Table class (complete version). You'll want to ...

View answer
WordPress classes explained
Accepted answer
10 votes

https://developer.wordpress.org/reference/ is sometimes more useful or other links on that page like Getting Started with WordPress. But you're better off with running Query Monitor to see what is ...

View answer
How do I access the body of a WP API request in a custom route?
9 votes

In a previous answer is was able to access the data in a custom endpoint using $parameters = $request->get_query_params(); Check the query params for option $parameters['option'] Two options for ...

View answer
Remove description from <title> on Home
9 votes

wp_get_document_title() has some interesting filters - pre_get_document_title and document_title_parts. /** * Filter the parts of the document title. * * @since 4.4.0 * * @param array $title { *...

View answer
Remove or Edit <dc:creator> in Feeds
8 votes

I was going to use the above answer from Otto but the more I looked at the templates the more it dawned on me that you don't need all that. Just hook the_author filter and check is_feed if you want a ...

View answer
Featured image shortcode
8 votes

Register the shortcode, ideally in a plugin or functions.php if you have to. add_shortcode('thumbnail', 'thumbnail_in_content'); function thumbnail_in_content($atts) { global $post; return ...

View answer
Use thumbnail image using url of that image
Accepted answer
7 votes

Get the image ID from the URL with attachment_url_to_postid(): $image_id = attachment_url_to_postid( $image_url ); Convert the ID to the thumbnail image URL with wp_get_attachment_image_src: $...

View answer
Turn Shortcode Gallery into Carousel in WordPress 4.4
Accepted answer
7 votes

You can piggyback off of the WP Gallery shortcode to render your slider. This example is adapted from the Owl Carousel Demo / Docs. To use it, create a WP Gallery and add the attribute owl="true". ...

View answer
importing third party json feed as custom post type
Accepted answer
7 votes

If you want the D.I.Y. route... The post type in this example is set to 'post' but you can see where to change it. Here is a working example to pull the data ( first page in this example ), parse the ...

View answer
Refresh wp.media after ajax call
Accepted answer
6 votes

So, I followed your links and this is working for me. This test works the same for my upload callbacks so hopefully it works for you. In the iframe function myTab_save_frame() { global $...

View answer
When is wp_loaded initiated only with admin or only when user enters the site or both?
Accepted answer
5 votes

wp_loaded fires for both the front-end and admin section of the site. This action hook is fired once WordPress, all plugins, and the theme are fully loaded and instantiated. Since you're checking ...

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
WordPress Rest API response
Accepted answer
5 votes

You might be able to output your headers with the response. Then just kill the request with exit();. The default is usually to return a value and let the process encode and output for you. Based on ...

View answer
Filtering multiple custom fields with WP REST API 2
5 votes

This solution works with get_items() in /lib/endpoints/class-wp-rest-posts-controller.php of the v2 WP Rest API. First, you'll want to construct the GET arguments like you would for a new WP_Query(). ...

View answer
Adding a body class with ACF
Accepted answer
5 votes

Hook into the body_class filter and add your field there. It might be better to get the ID from get_queried_object_id() instead of get_the_ID(). add_filter( 'body_class', 'wpse_20160118__body_class' )...

View answer
How to make gallery images responsive?
Accepted answer
5 votes

In order for your images to be responsive they require CSS. The CSS will inform the image to stretch 100% of the available space and to automatically adjust the height. img.responsive { width: ...

View answer
Using variable from one filter in another filter
Accepted answer
5 votes

This is probably a good case for a global variable. Just make sure it is set to an array before you add to it and also when to attempt to output the content. Convert the array to a string before ...

View answer
Unique URL Every Time
5 votes

Use add_rewrite_rule or add_rewrite_endpoint to capture the HASHorSOMETHINGcrazyANDrandom. Hashids could also help you generate a hash that you could read back later. $hashids = new Hashids\Hashids(...

View answer
Query WP REST API v2 by multiple meta keys
Accepted answer
5 votes

Adding a custom endpoint is pretty straightforward. I also modified the url to look more like http://example.com/wp-json/namespace/v2/posts?filter[meta_value][month]=12&filter[meta_value][year]=...

View answer
Pagination with 5 posts per page
5 votes

This is working for me on a single page using a template. Just be sure to set next_posts_link( 'Older Entries »', $the_query->max_num_pages );. // set the "paged" parameter (use 'page' if the ...

View answer
How can I serve a text file at a custom URL
4 votes

You can utilize add_rewrite_rule to create a new endpoint like http://example.com/api/files/xyz which processes the request and renders the contents from your server. This allows you to mask the ...

View answer
Add CSS animation as Preloader to WordPress
Accepted answer
4 votes

You can accomplish this by setting a class on the body and removing it with JS when the page is loaded. This is just a basic example but it'll work out of the box. // Add specific CSS class by ...

View answer
Passing parameters to a custom page template using clean urls
4 votes

add_rewrite_rule() allows you to turn the pretty url into variables. numbers: (\d*) section: /rid/ or /pageid/ slug: ([a-zA-Z0-9-]+ Here is a class to register the rewrite and handle the ...

View answer
Optimizing WordPress's styles and scripts
4 votes

Query Monitor will show you what is loaded or you can print them directly. function print_wp_scripts_queue(){ $scripts = wp_scripts(); echo "<pre><h1>scripts</h1>"; ...

View answer
Why functions.php file is called 8 time for just one page load?
4 votes

Add a plugin like Kint Debugger + Debug Bar and add the following code to your functions.php. global $wp; ob_start('kint_debug_ob'); d($wp); ob_end_flush(); When you check the Debug ...

View answer
1
2 3 4 5
13