Add attribute to existing Shortcode
Add attribute to existing Shortcode
Add attribute to existing Shortcode
Well, I found the solution. It seems that, when applying a rewrite rule on a custom post type post, one needs to tell WP the custom post type’s name within the rewrite rule itself. Here’s the code that does NOT work (redirects and drops parameter variables instead of rewrite): function add_rewrite_rules($rules) { $newrules = array(‘cpt-slug/([^/]+)/([^/]+)/?$’ … Read more
Two points: Your rule isn’t particularly specific. For numeric matches you should be specific about it and specify a) digits and b) how many digits. Year would be ([0-9]{4}), month/day would be ([0-9]{1,2}). You can’t do it with one rule. Add three separate rules instead. add_rewrite_rule( ‘whats-on/([0-9]{4})/?$’, ‘index.php?page_id=71&event_year=$matches[1]’,’top’); add_rewrite_rule( ‘whats-on/([0-9]{4})/([0-9]{1,2})/?$’, ‘index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]’,’top’); add_rewrite_rule( ‘whats-on/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$’, ‘index.php?page_id=71&event_year=$matches[1]&event_month=$matches[2]&event_day=$matches[3]’,’top’);
This should work, though untested. <?php add_action(‘send_headers’, ‘affiliate_redirect’); function affiliate_redirect() { // it’s possible to use ‘if( !empty( $_GET[‘affid’]) )’ if( isset($_GET[‘affid’]) && ” != $_GET[‘affid’] ) { if( empty($_COOKIE[‘affid’]) ) setcookie(‘affid’, $_GET[‘affid’], time()+2592000, “https://wordpress.stackexchange.com/”); header(‘Location: http://mysite.com/about/’); exit; } }
No need for a plugin, You can simply use the Oembed class’s oembed_result filter hook like this: function Oembed_youtube_no_title($html,$url,$args){ $url_string = parse_url($url, PHP_URL_QUERY); parse_str($url_string, $id); if (isset($id[‘v’])) { return ‘<iframe width=”‘.$args[‘width’].'” height=”‘.$args[‘height’].'” src=”http://www.youtube.com/embed/’.$id[‘v’].’?rel=0&showinfo=0″ frameborder=”0″ allowfullscreen></iframe>’; } return $html; } add_filter(‘oembed_result’,’Oembed_youtube_no_title’,10,3); so just paste this code in your theme’s functions.php file, setup the width and height … Read more
This is what I was looking for: /?s=+&author_name=username
I had the same problem on my large project that I currently work on. It’s case when you have collision between taxonomy and post-type slugs. Problem is that you can filter by taxonomy with adding ?taxonomy_name=term_slug and also you can see the custom post by adding ?post_type=custom_post_slug. So, that’s the same syntax, and WP doesn’t … Read more
They’re both doing the same thing. If you don’t pass a post ID, get_the_title() will just use the current post and go about it’s business. The performance difference between passing a postID and not passing a postID is, if anything at all, is extremely minor. get_the_title() Codex get_the_title() Core Function
In WordPress, name is a reserved term (emphasis mine): There is a complete set of reserved keywords, or terms, in WordPress that should not be used in certain circumstances as they may conflict with core functionality. You should avoid using any of these terms when: Passing a term through a $_GET or $_POST array Registering … Read more
Supposing you have a page created with the slug “referral”, you can add another segment to the page URL containing the employee ref number like this: 1- Register a new query variable e.g “employee_ref” add_filter(‘query_vars’, function ($query_vars){ $query_vars[] = ’employee_ref’; return $query_vars; }); 2- Using add_rewrite_rule function, add a new rule for the ’employee_ref’ to … Read more