Publishing just a Facebook URL without full code snippet

Note that Facebook is a registered oEmbed provider in the WordPress core. You could e.g. use the pre_oembed_result filter, before the HTTP request is made, to cancel it and override it to your needs. Here’s an example for Facebook posts: add_filter( ‘pre_oembed_result’, function ( $result, $url, $args ) { // override the HTML result for … Read more

Image change on hover

This isn’t really a WordPress-specific question, but generally you can do something like this via CSS (depending on the structure of the image). Generally, you’ll have an easier time doing this if the image in question is being applied as a background image to a DIV, rather than as just a standard img tag. Then, … Read more

Make a SQL query with wpdb in WordPress

The main problem is how you’re specifying the custom table name (e.g., $wpdb->cf7dbplugin_submits). $wpdb only knows about the “built-in” tables when accessing a table name via $wpdb->xxx. To specify access a custom table name, use {$wpdb->prefix}custom_table_name. The other thing I notice is that, for security purposes, you should never use interpolated variables in an SQL … Read more

How to remove ?p= from wordpress short links

I am not sure how you removed ?p= from the link but you can use get_shortlink filter to override the shortlink. You can refer following article for more details. http://www.wpbeginner.com/wp-themes/how-to-display-wordpress-shortlinks-in-your-theme/ Reference to get_shortlink filter: https://developer.wordpress.org/reference/hooks/get_shortlink/ Can you share some more details on how you removed the ?p= from the link?

(Woocommerce) Order by price when entering specific category

You can use the filter below, as suggested by @sabarnix at https://stackoverflow.com/questions/24939337/woocommerce-different-default-sorting-for-different-categories add_filter(‘woocommerce_get_catalog_ordering_args’, ‘tk_woocommerce_catalog_orderby’); function tk_woocommerce_catalog_orderby( $args ) { if( is_product_category( ‘shirts’ ) ) { $args[‘orderby’] = ‘meta_value_num’; $args[‘order’] = ‘ASC’; $args[‘meta_key’] = ‘_price’; } return $args; }

AMP – Change rel=”canonical” from functions.php [closed]

In general you can deregister the action’s callback, after it’s been registered and then register your own before it’s invoked with do_action( ‘…’ ). Here’s an example: // Add your own with later priority, e.g. 11 or wrap it in another later hook: add_action( ‘amp_post_template_head’, ‘wpse_amp_post_template_add_canonical’, 11 ); function wpse_amp_post_template_add_canonical( $amp_template ) { // Remove … Read more