Tag Info

New answers tagged

0

Use this metabox addon in your plugin. It is easy to use and add


1

This may be an alternative for you. The Advanced Custom Fields plug in has an Image Field, which allows images to be uploaded and selected. You can set the field to show on your Custom Post Type pages and also integrate a line of code into your template file. You can create as many image fields as needed. Learn more about the Image field here.


1

I don't think that you should touch these options. WordPress core already handles this, whether by removing the references to your plugin when it is deleted (as in delete_plugins()), or by being coded in such a way that it can ignore the reference to the removed plugin. Actually, none of these three options will last very long, since they are all regenerated ...


0

I found the solution. I Changed enctype="text/plain" to enctype="application/x-www-form-urlencoded" and that worked.


0

The order in which any plugins are loaded is not guaranteed and should not be relied upon. Instead, if you have processes which should happen after the plugins are loaded, then you should put those inside a function and then connect that function to the plugins_loaded action hook.


0

You are perfectly right about the analysis of the issue, even if the terms you employ are a bit confusing. There is no such thing as "an instance of the image" : once you have inserted an image into a post, modifying the original image title or caption (via the Media menu for example) will not modify the image inserted into the post. To convince you, click ...


1

You should not ship general purpose styles with any public plugin. There are two typical approaches to this: Don't ship any styles and rely on simple/expected markup. This works for cases like widgets, with similar enough markup between different themes. Same goes for outputting in content area — any quality theme is presumed to have styling for basic ...


1

The marked answer is wrong. Changing the version doesn't cause this to happen. The directory updates quickly, but not instantly. There is a delay and you need to account for that or just be patient. There is more than one server and not all of them update at the same time. Regarding your plugin, you have a couple of problems with it now: Your readme.txt ...


1

function get_custom_post_type_template($single_template) { global $post; if ($post->post_type == 'events') { $single_template = dirname( __FILE__ ) . '/single-event.php'; } return $single_template; } add_filter( 'single_template', 'get_custom_post_type_template' ); Source Or you could use: add_filter( ...


0

You need to capture the attributes that passed to a shortcode. You can do that like this add_shortcode('testimonial', 'testimonial_shortcode_func'); function testimonial_shortcode_func( $atts ) { $atts = shortcode_atts( array( 'style' => 'default_value_if_no_value_is_provided', ), $atts ); if( $atts['style'] == 'fancy' ) { //do ...


1

This is what I've always done. Not sure if you need both $wp_query and $post but it's always worked for me. Just put this in plugin-main-file.php /** * Add single template for events post type plugin */ function custom_template_events_post_type_plugin($single) { global $wp_query, $post; if ($post->post_type == "events"){ $template ...


2

I see the question is already answered. But there is a alternate scenario where you might want to redirect to settings page after a theme installed. You can do it very easily using following codes :) if (is_admin() && isset($_GET['activated'])){ wp_redirect(admin_url("themes.php?page=ot-theme-options")); } You just have to replace the ...


1

If you remove revisions, your blog is going to be identical for the user. Only in the backend, you won't have access anymore to your post history. You can also use plugins like https://wordpress.org/plugins/wp-optimize/ to do that. Ref: http://codex.wordpress.org/Post_Types#Revision


1

WordPress as a project has extreme commitment to backwards compatibility. Whatever new things you add the old things need to work still. Whatever things you change still need to work in old way as well. So regardless of how WP started as non–MVC application, it cannot become one without retaining all of its non–MVC ways. Which makes it pretty pointless ...


2

WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside "Blog pages show at most". You can override that number in your custom queries a couple of ways but I would first recommend against the use of query_posts() ( take a read at the link for the reasons why) in favour of ...


0

Try this: query_posts( 'posts_per_page=-1' ); Just a head up, you shouldn't be using this function here, do whatever you want, but is recommender to use WP_Query or get_posts


0

The global $wp object contains the current request, which can be used to get the current URL anywhere on the site. A helper function like the following demonstrates how this works: function wp157715_current_url() { global $wp; $current_url = trailingslashit( home_url( $wp->request ) ); return $current_url; }


0

you can use bloginfo('url') but also can use get_option function, check documentation: http://codex.wordpress.org/Function_Reference/get_option and by the way we cannot access your localhost :)


0

As posed in question the way to retrieve the current URL to the root of the site would be home_url() for site's front-end. However there are multiple functions that deal with URLs to specific kinds of pages. It's not clear what you are linking to (post? page? archive?), but there are likely specific URL-forming function for it which should be used over ...


1

bloginfo('url') should get you the URL for the installation. EDIT: I guess you could also use get_permalink()


0

<?php echo get_the_title( $post_id ); ?> <?php get_post_image($post->ID,'large'); ?> You can customize these to your liking. or just go to http://codex.wordpress.org/Template_Tags/get_posts


2

Instead of using poedit to generate your translation strings from your code, use the WordPress i18n tools to generate a POT file for you. This has the advantages of a) not needing you to do anything special in poedit and b) getting everything that is possible for translation, including headers and non-standard translation string calls (not everything is __ ...


0

wp_get_archives() can not display post date, but you can force wp_get_archives to display date by using hook. Put the following function at the end of your custom template file or functions.php file - function wpse_the_title($title, $id){ if( $date = get_the_date('d/m/Y', $id) ){ $title = sprintf('%s - %s', $date, $title); } return ...


1

Ok. I Found the problem. Several tutorials told me to put __() and _e() in my poedit. Which, now I've found the answer is pretty stupid. Because there simply don't exist any strings with these search values. As there is always something in between those brackets. Solution is thus very simple (and quite stupid). Put the search values to __ and _e


1

There is the post type attachment, which is normally used to store information about files uploaded to WordPress' Media Library. Additional data can be saved into custom fields/postmeta. You definitely should look into that, if you decide to go with native WP tables. Another possibility would be to make those custom tables searchable, on the codex page ...


0

Extra bonus Easter Egg for those in need... After the foreach loop by adding... $output .= get_post_field('post_content', $related_post->ID); You will also get the current post content.


1

OK, you have two problems here. Firstly, you are enqueueing your style with wp_enqueue_script(), which is meant to be used by scripts. You should be using wp_enqueue_style Secondly, you need to understand what functions are loaded when. Plugins are loaded first, child themes second and parent themes last. So you styles gets loaded first, and then the ...


0

Ok guys found the solution myself (5 days later, oof) added below to help someone else in the future... foreach((get_the_category( $related_post->ID )) as $category) { $output .= "<a class=\"$category->slug\" href=\"".get_permalink( $related_post->ID )."\" title=\"" . $category->cat_name . "\">" . ...


0

To remove a plugin from the WordPress repository, first delete the code via SVN. Then email plugins@wordpress.org using the email you registered with at wordpress.org (for the account that is the author of the plugin). They will delete it within a few days and email you back to confirm. They basically hide the plugin pages. The plugin slug remains blocked ...


0

I think something exists in Wordpress 3.9 that might help you. It's the widget-updated callback. Use it like this (coffeescript): $(document).on 'widget-updated', (event, widget) -> doWhatINeed() if widget[0].id.match(/my_widget_name/)


0

You should be using the template_include filter hook This filter hook is executed immediately before WordPress includes the predetermined template file. This can be used to override WordPress's default template behavior.


1

The unexpected output is the blank lines betwen ?> and <?php. Avoid to close php tags and open them again with no reason. In your code, remove all the closing php tags (?>) and leave only the opening tag on first line.


0

USE DEBUG: (creates log file error_activation.txt in your plugin folder) add_action('activated_plugin','my_save_error'); function my_save_error() { file_put_contents(dirname(__file__).'/error_activation.txt', ob_get_contents()); }


0

I solved it. This line: "if (!isset($pd_plugin_instance)) $pd_plugin_instance = new Products();" Was causing all the error. I removed the Widget section from the plugin but forgot to remove it. After removing it, the error was gone.


2

In practice in wordpress the number of SQL queries has the biggest impact on the performance of the site and the quality of the PHP code is usually irrelevant. In theory for any additional PHP file that you include you delay your code by the time needed to fetch the file from the disk. This time can be small if the fike are memory mapped or big if it rund ...


0

After some researches I came across two plugins using WebRTC : Collaboration, which is a simple integration of TogetherJS wpRTC which is not enough mature yet but look promising !


0

$response_radio = $_POST['meta-radio']; if ($response_radio=="radio-one") { //do your stuff } elseif ($response_radio=="radio-two") { //do other stuff } I think this is what you are looking for


0

From what I get in you question, I think you should create 3 taxonomies within the Custom Post Type UI plugin. Call these FOOD, MUSIC and CRAFTS, and attach them to the custom post type you created. Then you'll proceed to adding the specific items to each taxonomy. And these will automagically appear in your post-edit screen either as a text-field with ...


2

You can probably use the language_attributes filter (from the language_attributes() function) to add it. It should receive an output like lang="en" and you can add to it before printing to the <html> tag: add_filter( 'language_attributes', function( $attr ) { return "{$attr} manifest=\"manifest.appcache\""; } ); or without a anonymous function ...


2

I think those of us who have been working with Wordpress for a few years have been guilty of doing this at one stage or another. I have had to make modifications to a plugin that was no longer being supported by the original author and had some compatibility issues with later versions of Wordpress. There are situations where editing an existing plugin ...


5

In general you don't want to modify plugins, because you will loose your modifications next time you update them. It's a little bit different for themes, where you can set up a child theme. If the plugin is using the wp_mail() function to send out the emails, you might try to use the wp_mail filter to change the recipients. Try to write your own plugin to ...


4

The most important question which you must ask yourself is Am I the author of the theme or plugin?. If your answer is yes, and you are responsible for the up keep of the plugin or theme, go ahead and change it and modify as you like. If your answer is no, then you should not make any changes to it, not even a small thing as a simple dot .. The same goes for ...


0

Please check the callback function name for example add_action( 'woocommerce_process_product_meta', 'new_metabox_save',35 ); Function definiton function new_metabox_save(){ $post = get_post( $post_id ); }



Top 50 recent answers are included