Tag Info

New answers tagged

0

You have two options here In a child theme, dequeue and deregister the scripts and style you are not going to need. Just remember to hook your function to wp_enqueue_scripts with a lower priority (higher number) Use the twentyfifteen as a base to a new theme. I have successfully used bundled themes in the past to create new, selfstanding themes. That is ...


0

Your code won't work in a themes functions file unless it includes a hook. Try something like: add_action( 'loop_start', 'your_function' ); function your_function() { if ( is_user_logged_in() ) { echo '<li id="text-2" class="hide">'; } else { echo '<li id="text-2">'; }}


1

You are almost there. You just need to use wp_mail to send emails containing in your array. Here is how you can achieve that using save_post action hook. /** * To send email on updating your event post * * @param int $post_id The post ID. * @param post $post The post object. * @param bool $update Whether this is an existing post being updated or not. ...


0

... from a custom Wordpress page template to my child theme functions.php file... You can't. And a global variable won't help. The theme's functions.php file loads first, before any other templates load. You can't pass variables backwards to something that has already loaded. What I think you want to do, based on what your code appears to be trying ...


0

Use my way <?php $commentscount = get_comments_number(); if($commentscount == 1): $commenttext = 'comment'; endif; if($commentscount > 1 || $commentscount == 0): $commenttext = 'comments'; endif; echo $commentscount.' '.$commenttext; ?> its working in all version.


0

To grab the img tag as a variable: get_the_post_thumbnail ( int $post_id = null, string|array $size = 'post-thumbnail', string|array $attr = '' ) or if you want to outright echo it: the_post_thumbnail ( string|array $size = 'post-thumbnail', string|array $attr = '' ) Most things like the post content, excerpt, title etc, are acquired using functions ...


0

1) You can create an account on AddThis. There's a Wordpress plugin for Addthis. 2) You can go to wordpress's plugins page and make a search for: "share", "social" or other words. There are plenty of plugins that you can use. Try for example this search. EDIT 3) You need to create custom fields. Search on wordpress.org/plugins for a module called ...


0

You should write a function that displays your dates in the desired way. function wpse195313_custom_date() { global $post; $theDate = $post->post_date; // check whether minutes are 00 // use mysql2date function https://codex.wordpress.org/Function_Reference/mysql2date if ( mysql2date('i', $theDate, false) == 00 ) : ...


0

For adding JavaScript code in WordPress, you can create a .js file and include it in following way, in your theme's functions.php /** * Proper way to enqueue scripts */ function theme_name_scripts() { wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', ...


0

You can simply use require, require_once, include or include_once functions to include custom PHP files in your theme. require( 'folder/custom.php' ); Usually you should keep your custom PHP files in a folder. Developers vote against using require_once because it is a little slower than require since it requires the system to keep a log of what's already ...


1

You need to wrap the first three || conditions in additional parentheses so they are evaluated first BEFORE the last && condition: Psuedocode example: here here ↓ ↓ if ( (condition || condtion || condition) && ! condition ) { //do business logic... } This now ...


1

I don't suspect that your tax_query is failing you, but actually your tag parameter is. single_tag_title() returns the name of the tag, not the slug. All tag and category queries are converted to a tax_query in the WP_Query class before being passed to the WP_Tax_Query class to build the relative string for the SQL query. Term names and slugs gets ...


0

I played with the code for a bit longer and managed to get it working. Answer below add_filter( 'gform_pre_render', 'freetrial_studios' ); add_filter( 'gform_pre_validation', 'freetrial_studios' ); add_filter( 'gform_pre_submission_filter', 'freetrial_studios' ); add_filter( 'gform_admin_pre_render', 'freetrial_studios' ); function freetrial_studios( $form ...


0

loop through the roles and merge the results... this will work with any number of roles. $roles = array('academic','student'); $users = array(); foreach ($roles as $role) { $args = array('role'=>$role); $usersofrole = get_users($args); $users = array_merge($usersofrole,$users); } foreach ($users as $user) { echo '<li>' . ...


0

Some of the functions are in wp-includes/pluggable.php, notably wp_authenticate() though you'll notice that most of the work is done by filters hooked to authenticate. The names of those you can find in wp-includes/default-filters.php and the function definitions in wp-includes/user.php. But be aware that functions in pluggables.php can be replaced by theme ...


0

Using the following modifications and adding in die() stopped the script and output whatever the variables value was at that time. Thanks to @toscho function cf7pp_after_send_mail( $contact_form ) { global $postid; $submission = WPCF7_Submission::get_instance(); if ( $submission ) { $posted_data = $submission->get_posted_data(); ...


2

The short answer to your question is yes; however, the methods to do this are a little bit hacky and generally I would recommend against all of them unless absolutely necessary. Since pluggable functions actually replace the stock function by way of function_exists() whichever plugin that "plugs" the function first will win. What you want to do is ensure ...


0

Child theme's can have their own header.php file, right? So why not just simply drop a child header.php file into the child theme's folder, then add the code there? Unless I'm missing something, this does seem to be the simplest solution.


0

I found a solution to my problem. What I did is the following: First I created a new page in Wordpress with the php that creates the product that has a link like: www.mypagename.com/myphpcode The php is the following: `global $woocommerce; $my_post = array( 'post_title' => 'My title', 'post_content' => 'This is my post.', 'post_status' ...


0

It turns out that some themes disable functions.php for the backend, in order to prevent a complete lockout. The way they do this, is by simply doing an is_admin() check. However, since all AJAX is ran through admin-ajax.php, this returns true, and the theme functions are not loaded. In this particular case (Genesis Framework (theme) with Dynamik website ...


0

The following code will redirect any page except homepage to login page. function my_redirect(){ if ( in_array( $GLOBALS['pagenow'], array( 'wp-login.php', 'wp-register.php' ) ) ){ return; } if(!is_home() || !is_front_page()){ wp_redirect( wp_login_url() ); exit; } } add_action('init','my_redirect');


0

Set your posts/pages as "password protected". In the Publish box when editing/creating a post, change the visibility from public to password protected UPDATE You'll need to use some rewrite rules to redirect everything to the root URL. The first condition redirects everything to the root URL, the second condition adds exceptions for images, css, javascript ...


0

I have found a work around for this that works in IE, Chrome and Firefox. And instead of using php approach decided to utilize jQuery. It is not a complete solution but will work in a pinch for anyone else out there that needs to apply this as well. <script type="text/javascript"> /*! jQuery script to hide certain form fields */ ...


2

using wp_die(); at the end of AJAX function fixed the issue for me. e.g add_action( 'wp_ajax_my_ajax_function', 'my_ajax_function' ); function my_ajax_function(){ echo json_encode($myvar); wp_die(); }


0

I think the query we run is maybe limited in some way... So far as I know, your query and the processing you do of the results is going to be limited by server resources-- memory, etc-- not by WordPress other than the WordPress defined PHP memory limit, to some extent. You can try altering that and see if it helps. Otherwise, you will need help from ...


0

Yeah I think it works with limited no of items, I have also find similar issue with wp_query, on my client's site, there are 20,000+ products were there, btw I did resolve this by executing sql query,instead of wp_query. ;)


0

You could try serializing the array so that it becomes a flattened textual representation of the values it contains. e.g. $testArr = [3,4,"test", 56]; echo serialize($testArr); gives: a:4:{i:0;i:3;i:1;i:4;i:2;s:4:"test";i:3;i:56;} However, you should probably consider using user sessions for this rather than cookies.


0

@GrSrv It is not possible in vanilla WordPress as the tags, and categories are separate entities. Categories would offer you a hierarchical parent/child relationship, and could accomplish this. CategoryParent1 CategoryChild1 CategoryGrandchild1, CategoryGrandchild2, CategoryGrandchild3 CategoryParent1 CategoryChild2 CategoryGrandchild1, ...


0

The get_search_form function doesn't work like that. The parameter that is accepted only specifies if the HTML content is being returned or outputted directly. So this parameter should be a boolean. It still works in your case because PHP simply evaluates the string that you are passing as true considering that it is not an empty string, 0, null etc. It ...


5

You can hook onto pre_insert_term, check the taxonomy and whether or not the user has the specified role as follows: function disallow_insert_term($term, $taxonomy) { $user = wp_get_current_user(); if ( $taxonomy === 'post_tag' && in_array('somerole', $user->roles) ) { return new WP_Error( 'disallow_insert_term', ...


0

You should run your register_activation_hook after creating object. class Notification { function jal_install() { global $wpdb; global $jal_db_version; $table_name = $wpdb->prefix . 'fnotice'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE ...


0

Can you place custom .php files directly inside the child theme folder? Some of the research we found says you must write your custom PHP functions inside of the functions.php file. You can put in the folder directly and use it. Child theme templates work in a hierarchy. Child theme overrides the parent theme folder, so if you want to modify a ...


0

Can you place custom .php files directly inside the child theme folder? Yes, of course you can. WordPress is PHP. What works in PHP works in WordPress. Some of the research we found says you must write your custom PHP functions inside of the functions.php file. Nonsense. Many themes segregate code into multiple files, including "Twenty ...


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 ...



Top 50 recent answers are included