Tag Info

New answers tagged

0

To sort by meta fields you need to use meta_key and meta_value (or meta_value_num): array( 'meta_key' => 'sort_order', //This is the custom field to orderby 'orderby' => 'meta_value_num', //for numerical values 'role' => 'Administrator', 'fields' => 'all_with_meta', ); However... This will probably order the results before ...


0

I will say, I don't exactly understand your words "when a front-end sets a date"... I'm assuming wp-admin setup. Go find a post expiration plugin. There seem to be more than a couple of these out there. The plugin I've used ws "Post Expirator" Awesome tool. You can create a start posting and stop posting date when the post is created. I used it on a ...


1

Your code has a couple of flaws which I'm not going to go into detail now. Here is a short list pre_get_posts is an action On any type of archive page you need to make sure you only target the main query and the front end when using pre_get_posts Your syntax is very hard to debug and not supported by most code editors. Although if (): else : endif; is ...


0

Not necessary, you echo the value on the traitement page, and in your ajax request, you get put the echo in a variable, like : resultats = ajax.responseText;


0

You can't override the function(s). They aren't meant to be overwritten. See: "Override parent theme function that is not hooked or in the functions.php file" and "Is it possible to disable a function of a parent theme?". That is the direct answer to your question. You can, however, almost certainly achieve the result you want by using the filter provided ...


0

Have you tried adding the unfiltered_upload capability too? function add_theme_caps() { // gets the author role $role = get_role( 'subscriber' ); $role->add_cap( 'upload_files' ); $role->add_cap( 'unfiltered_upload' ); } add_action( 'admin_init', 'add_theme_caps'); add_action( 'init', 'add_theme_caps');


1

The plugin you mentioned is only reportedly tested up to WordPress version 3.6.1. I would not (in general) recommend abandoned plugins, because they might impose security risks. Additionally it uses PHP4 class constructors, that might soon be deprecated and it calls non static methods in a static way. If you remove the plugin, you should be able to use ...


-1

I have not tested but the following code will help you please add the following two lines of code to your function.php file $role= get_role([role_name ]); $role->add_cap('upload_files');


0

If you want the absolute path to your theme's stylesheet directory you could use get_stylesheet_directory(). If you want the URI of your theme's stylesheet directory you could use get_stylesheet_directory_uri(). get_theme_root() will return the absolute path to the themes directory. get_home_path() will return the absolute filesystem path to the root of ...


2

Another option is: <?php echo str_replace('Brand: ','',get_the_archive_title()); ?> Replace Brand: with whatever text you are wanting to get rid of. Its worth looking into the difference between get_the_archive_title() and the_archive_title() the_archive_title() returns an array get_the_archive_title() returns a string


0

get_XXXXXXXXX() get_ functions always return a value.. so you should do echo always with it: <?php echo get_permalink();?>


0

this will removes all of the theme_mod settings function reset_newtheme_options() { remove_theme_mods(); }


4

I doubt it would justify the effort of writing custom SQL queries for only 2500 posts. Within the wp_set_object_terms( $object_id, ... ) function we have: $object_id = (int) $object_id; so it's correct that it only takes a single post id as input. So you would need to loop over your $post_ids array but it might be sufficient to use the ...


0

As what I've commented, the rawurlencode() function is the reason because WordPress have a lot of restrictions. I found that, that kind of problem will exist if you have a % percent sign (in my case, produced by the rawurlencode()) in your 'default' => $value. One of the solutions, encode some or the whole part of your path with base64_encode(): $encode ...


0

I found that there's a predefined WordPress function to upload a file into the Media Library but it's only working asynchronously with a <form> element and a $_FILES array. Second, I also found that there's a second imagepng() parameter filename which is the path where you want to save the file. I tried to save it to a WordPress uploads' path such ...


0

One of the solutions that I've found, is to store the set get_theme_mod($name) into a PHP $_SESSION["$name"]. If the session exist, compare the new get_theme_mod($name) to that old $_SESSION["$name"], if they're not the same then // do something..: // Check if the user is an admin for validation to improve performance. if (current_user_can( 'manage_options' ...


1

See Wordpress Template Hierarchy and figure out which page you've to modify. From this figure, it's easy to see that if you want to modify your homepage, you have to modify frong-page.php. It it doesn't exist, check if a custom page template is used to serve the home page and edit that page template. If front-page.php doesn't exist and you are not using ...


1

You could use get_attached_media() function to check if the post has any attached images to it. Also, you use wrong logic operator. Your code would look like this: $attached_images = get_attached_media('image', $post->ID); if ( (get_the_post_thumbnail() == NULL) && empty($attached_images) ) { // show your default image } else { // do nothing, I ...


0

Thanks a lot. I have checked and i found that the problem is on the Theme-options code. i have used Option tree plugin inside of my theme instead of installing the plugin. But I don't know why it works on local and doesn't work on website.


0

Ah, I see a few places where I went wrong. For one, in the switch statements, when I tried to return answers using echo, I was using parentheses, which work fine in one offs, but apparently cause an error in a function(?). Thanks to the one who edited my first code! I would not have seen that. So when I changed this: switch($graphic[0]) { case 1: ...


1

This answer will be long, but can be helpful in some way. First of all, detect why you're getting this error: Majority of the time when you see a Wordpress' White Screen of Death, it means that you exhausted the memory limit of your server settings. This could be caused by a plugin that you may be using that is not functioning properly. It could also ...


0

The hooks are important, no matter how we sorted form fields inside the function. Follow my inline comments. As of WordPress 4.2.2 we have plenty of hooks now: <?php /** * Declaring the form fields */ function show_my_fields( $user ) { $fetched_field = get_user_meta( $user->ID, 'my_field', true ); ?> <tr class="form-field"> ...


0

It's a bit hard to answer with not much information, but here are some things you can try and ask yourself: Reset your permalinks (Settings > Permalinks > Save Changes) What happens when you set WP_DEBUG to true in your wp-config.php file? Is this a custom post type, or was anything recently changed that may have caused this?


0

I would try using the Query Monitor plugin This will help you troubleshoot your problem by showing you the db query's, hooks, actions, and filters for the active page.


2

If you define your own empty function, then it can cause a problem when the plugin tries to load its same function. The simplest way around this is to use PHP's built-in function_exists() method wrapped around the function call. If that function is defined (like inside the plugin) it'll run the call. If not, it's skips over it without a second thought. if ( ...


0

It is not good practice to use constants. For this functionality one should ALWAYS use the plugins_url() function seen here in the codex. function load_my_alerts(){ wp_register_script( 'my_alerts', plugins_url('js/alerts.js'), array( 'jquery' ) ); wp_enqueue_script( 'my_alerts' ); } ...


1

Normally Wordpress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags. Add the following in your template file, it can be single.php ...


0

The Correct syntax for writing a add_filter // Define the woocommerce_short_description callback function filter_woocommerce_short_description( $post_excerpt ) { // make filter magic happen here... return $post_excerpt; }; // add the filter add_filter( 'woocommerce_short_description',filter_woocommerce_short_description',10, 1 ); Your code ...


0

If you see the code, there is no hook to do that. But you can create your own function and remove the part that you don't need like this function custom_wp_install( $blog_title, $user_name, $user_email, $public, $deprecated = '', $user_password = '', $language = '' ) { if ( !empty( $deprecated ) ) _deprecated_argument( __FUNCTION__, '2.6' ); ...


1

Your problem is that you've used the get_template_directory_uri() function for your include path. As indicated by the function name, this returns a URI (not a path), which is no use for including one php file into another. Simply enter the relative path of the file to be included. E.g. if your structure is: /my-theme |--functions.php |--/lib ...


0

In my opinion, your functions file can be as big as you want it, but organizing functions into includes is a very logical process. I would first check that get_template_directory_uri() is returning the correct path. You can also include files without the full path within your theme if /admin/ is in your theme root: ...


2

I always break my functions.php up into more managable, specific functionality files, for instance, all footer related functions goes into a file called footer-functions.php and pagination functions goes into a file called pagination-functions.php. This way, my code stays organised, managable and I don't kill my functions.php. This however, is only related ...


2

I needed to do something very similar for one of the plugins that I was developing. I registered two separate cpt's during plugin activation, and each of those cpt's should use a custom single template that I had bundled with the plugin code base. You should be able to do the same for page templates, using the page_template filter. Here is my function ...


1

Here is an idea but before we go into details, here are VERY VERY IMPORTANT notes NOTE: READ THIS FIRST Take a database back up before running this code. It is advisable to run this on a local install first for testing purposes. Note on wp_trash_post(), from the codex If trash is disabled, the post or page is permanently deleted. I have tested the ...


0

The $protocols parameter accepts an array, so: $protocols = array( 'https' ); But "https" is listed as a default so I am not sure that is the problem. My guess is that there is a filter interfering... clean_url for example, or kses_allowed_protocols


0

esc_url never force the URL to protocol it's only checking and escaping the passed URL from invalid characters, the $protocols variable is an array of acceptable (white list) protocols not for forcing destination URL. // Forcing URL to https instead of http $YOUR_URL = esc_url($YOUR_URL); if( 'http' == parse_url($YOUR_URL, PHP_URL_SCHEME) ){ $NEW_URL ...


1

Use this instead: Concatenate the html then return it. function check_my_login( $atts) { $html = '<form action="" name="" method="post" enctype="multipart/form-data">'; $html .= '<div class="form-group">'; $html .= '<label for="description">Project Description</label>'; $html .= '<textarea name="p_description" ...


3

Change this line setcookie( 'cookiename', 'cookievalue', time() + 3600, 'mysite.net/sites/site1/', 'mysite.net/sites/site1/'); to setcookie( 'cookiename', cookievalue, time() + 3600, COOKIEPATH, COOKIE_DOMAIN);` COOKIEPATH and COOKIE_DOMAIN are WP constants now, but the codex is not updated yet.


0

Take a look at Tom's answer on a similar question. He hooks into an action that adds a rewrite rule to the database so the post is accessible through both slugs. He was not actually able to redeclare the slug, but he shows how you can hide the old slug so that it appears the new one is the right one. Another option suggested by Dustin is to call ...


0

I'm currently experimenting with adding support for pre-processors in Kirki. You can find instructions on how to use that here: https://github.com/reduxframework/kirki/wiki/variables Please note that the above only works with the github version of the plugin as it's not stable and still under development. If all you want to do is avoid inline CSS in the ...


3

get_the_utm_vars doesn't work like you think it does. A function cannot return more than one value. Right now, when the first return is reached, that value is returned and none of the following lines are ever reached. You could have get_the_utm_vars return an array of values instead: function get_the_utm_vars(){ $utm = array(); $utm['source'] ...


0

I supposed that you are trying to set defer for every JS exclude jquery.min and jquery.ui.core.min. Based on that I have made some changes into your code and this will set defer for all JS exclude given example files jquery.min and jquery.ui.core.min. function add_defer_to_cf7( $url ) { //If not js file OR js file with 'jquery.ui.core.min' OR ...


0

The get_media_embedded_in_content() function is a handy helper function, though it doesn't seem to be used in the core (ver. 4.2.2). Regular expression: To understand the get_media_embedded_in_content() function, we must understand the following regular expression: ...


0

Actions and filters are intended to allow third part code (though Core uses a lot of actions and filters as well) to modify how WordPress works without hacking the code. That is, hooks allow WordPress to be extended and altered without requiring hackers to modify the main body of code, which would be a nightmare when a new release comes out. Hooks are not ...


1

The main benefit with hooks ( such as add_action ) is that they allow you to add additional logic very easily based on priority. The only way to achieve the same thing with a standalone function is to edit the function directly. You wouldn't want to do this in premium theme ( or core ) as any time there's an update your function will be overwritten. Take ...


1

Since WordPress 3.6+ There is a function to print out all the media in the content. get_media_embedded_in_content();


0

Here a little function which takes care to hide (In admin) Custom Post Types. function remove_from_admin_menu(){ // Check capability (admin) if( current_user_can( 'edit_dashboard' )){ //Do nothing } elseif ( current_user_can( 'moderate_comments' ) ) { // editor capability remove_menu_page( 'edit.php?post_type=cpt01' ); // add ...


0

cat is a reserved query variable used for the ID of a post category. To avoid conflicts with WordPress and/or other plugins and themes I'd recommend you 'namespace' your query variables eg eddh_cat instead of cat


0

should I copy the code from the link provided? http://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme it's a twentytwelve theme, my theme is oxygen theme, how can I impliment the code? change the word twentytwelve into oxygen?



Top 50 recent answers are included