Wp_redirect and sending variables

I’m afraid that you can’t do it this way. wp_redirect is a fancy way to send header Location and the second argument of this function is request status, and not custom variable. (404, 301, 302, and so on). You can send some variables as get parameters. So you can do something like this: if ( … Read more

Add image size if page template

This has always been a bugbear for me – the lack of on-demand image sizing, and the subsequent number of files you can end up with if you have lots of sizes! I can see the logic behind your efforts – the trouble is, add_image_size only truly comes into play at point-of-upload. As such, is_page_template(..) … Read more

don’t publish custom post type post if a meta data field isn’t valid

You can stop the post from saving all together with minor JQuery hacks and validate the fields before saving on the client side or server side with ajax: first we add our JavaScript to capture the submit/publish event and use it to submit our own ajax function before the actual submit: add_action(‘wp_print_scripts’,’my_publish_admin_hook’); function my_publish_admin_hook(){ if … Read more

Why use admin-ajax.php and how does it work?

1) Why use admin-ajax.php instead of encoding your json in a separate file like themes/example/json.php and encode your data there? Using admin-ajax.php means that the WordPress Core is loaded and available. WIthout that, you would need to hand load the files you need, which is a complicated process and prone to failure if you don’t … Read more

Add tags to the section via functions.php

The hook you’re looking for is specifically wp_head which could look something like this: function theme_xyz_header_metadata() { // Post object if needed // global $post; // Page conditional if needed // if( is_page() ){} ?> <meta name=”abc” content=”xyz” /> <?php } add_action( ‘wp_head’, ‘theme_xyz_header_metadata’ ); I believe in the long run though, since WordPress is … Read more

How can I control the Facebook like image? [closed]

The image that is used for sharing is taken from a chunk of code in the header of your site that will look something like this: <link rel=”image_src” href=”https://wordpress.stackexchange.com/questions/3605/path/to/theme/screenshot.png” /> Typically it links to the screenshot of your site in the theme. If you removed the code from the header of the file and on … Read more

Plugins in mu-plugins folder are not loaded

Does WordPress only loads plugins which are just single files in mu-plugins? No, they do not need to be single files but you cannot use plugins in their own subfolders as in the standard plugins/ folder. The main plugin file (one with the specified plugin header info) has to be right there in mu-plugins/. Other … Read more

Filter by custom field in custom post type on admin page

And for displaying result for Filter then try this code add_filter( ‘parse_query’, ‘prefix_parse_filter’ ); function prefix_parse_filter($query) { global $pagenow; $current_page = isset( $_GET[‘post_type’] ) ? $_GET[‘post_type’] : ”; if ( is_admin() && ‘competition’ == $current_page && ‘edit.php’ == $pagenow && isset( $_GET[‘competition-name’] ) && $_GET[‘competition-name’] != ” ) { $competition_name = $_GET[‘competition-name’]; $query->query_vars[‘meta_key’] = ‘competition_name’; … Read more