How to make a rest style plugin?

I got a little piece of code here, but it should/could probably be improved. Create new query_vars Create new rewrite rule Redirect to specific template which then handles your parameters Create new query vars function register_gallery_query_vars($vars) { $vars[] = ‘gallery_id’; $vars[] = ‘image_id’; return $vars; } add_filter(‘query_vars’, ‘register_gallery_query_vars’); Add rewrite rule function custom_rewrite_gallery() { add_rewrite_rule(‘^gallery/([0-9]+)/([0-9]+)/?’, … Read more

Two types of layout in woocommerce SHOP page [closed]

Set a button, or dropdown menu, that calls a function to set a cookie and to switch between CSS files which contain the _style ID: function switchStyle(style) { var file = $TMPL_URL + ‘/css/’ + style; jQuery(‘head’).append(‘<link rel=”stylesheet” href=”‘ + file + ‘” type=”text/css” />’); jQuery.cookie($TMPL_NAME + ‘_style’, style, { expires: 365, path: “https://wordpress.stackexchange.com/” }); … Read more

How to get only post=’product’

If I understand you, what you are doing is wildly complicated. All you should need is a simple pre_get_posts filter: add_filter( ‘pre_get_posts’, ‘modified_pre_get_posts’ ); function modified_pre_get_posts( $query ) { if ( $query->is_search() ) { $query->set( ‘post_type’, ‘product’ ); } return $query; } Plus your filter that adds DISTINCT. post_type is a query parameter rolled into … Read more

Grouped Custom Meta Fields without plugin

stick with cmb2 — there is another method of displaying and then saving meta data, but it’s a PAIN and loads your functions file. the plugin pretty much has no effect on the front end of the site — it’ll also make your meta boxes a lot cleaner and consistent-looking

Why are many options missing from the editor?

Switch your editor to use the visual mode instead of the text mode. You’ll find this on the right-hand side of your editor. Also, see the item with a grey box around it in the below image. That’s the “kitchen sink” button. It toggle’s the rest of the toolbar for a deeper list of options.

Assign class to Drop Down Selections in WooCommerce Products Custom Fields

You can do in the following way! Create an array of CSS class names and message values $colors_stings = array( ‘Message one’ => ‘message_color_green’, ‘Message two’ => ‘message_color_red’, ‘Message three’ => ‘message_color_blue’ ); Check if message string exist in array then assign CSS color class to variable. $css_class = isset($colors_stings[$product_status]) ? $colors_stings[$product_status] : ‘message_default_color’; Complete … Read more

Embed php code in custom field of a plugin [closed]

Looking at the Other Notes of the plugin, you can use one of the variables to insert the post url. $post_url – Replaced with the URL of the post which was published Edit: You would just add the $post_url variable within your body field. <a href=”https://wordpress.stackexchange.com/questions/226286/$post_url”>$title</a>