Tag Info

New answers tagged

0

I resolved this by using another php file to use from the command line with just a line like this: file_get_contents('url to file I want to run'); the problem with using wordpress function in files outside of wordpress is that wordpress is bound to its installation so you gotta run it from an url belonging to the wordpress setup I think


0

WordPress has a command line library called WP-CLI. You can extend it to create your own commands. I would recommend this for any work on the command line.


0

You can use the following function and filter hook function filter_woo_cart_quantity($output, $cart_item, $cart_item_key){ return '<span class="quantity">' . sprintf( '%s &times; Quote', $cart_item['quantity'] ) . '</span>'; } add_filter('woocommerce_widget_cart_item_quantity','filter_woo_cart_quantity',10, 3);


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


0

Yes, multisite is not what you need here. I would try to map all subdomains on the same wordpress install, and then customize the template via the current URL. In the wp-config.php you then use the current URL as base url: define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); define('WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']); You can also do ...


0

Following on from @Otto, you need to capture the output from the action, and then pass it through the shortcode: ob_start(); do_action( 'tribe_events_single_event_after_the_meta' ); $calendar = ob_get_clean(); $password = get_post_custom_values( 'password' ); if( ! empty( $password ) ) { echo do_shortcode( "[content_protector ...


1

I found a solution with a recursive function function decomposePrice($base, $iValue, $values, $prices) { $d = array(); foreach ($prices as $i => $p) { $baseP = "$base{$values[$iValue][$i]}|"; if (!is_array($p)) { $d[$baseP] = $p; } else { $d = array_merge($d, decomposePrice($baseP, $iValue + 1, ...


0

with your code, you have this : +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_color = C1 attribute_fabric = F1 attribute_fabric = F2 +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_color = C2 attribute_fabric = F1 attribute_fabric = F2 +++++++++++++++++++++++++++++++++++++++++++++++++++ attribute_fabric = ...


1

You need to use get_stylesheet_directory_uri() instead of get_template_directory() in your child theme. From the WordPress codex: get_template_directory_uri() In the event that a child theme is being used, the parent theme directory URI will be returned. get_template_directory_uri() should be used for resources that are not intended to be ...


0

a) Change css style-sheet for table devices.. if steatment didn't bypass the function I just make a mistake in the @media screen b) fixing with the following: function wpse120407_pre_get_posts( $query ) { if(is_mobile()) { $query->set( 'posts_per_page', 2 ); }else{ $query->set( 'posts_per_page', 10 ); }} ...


0

Run phpinfo();. If you don't see xDebug enabled then you will need access to PHP.ini to enable it. Also may have to install it on the server through the package manager or pear. Ask your server administrator / hosting provider about enabling it.


-1

As toscho pointed out, use jQuery(document).ready(function($) { ... }); instead of $( function() { ... }); Edit: Main problem is WP rich text editor escaping your html <script> tags. See https://codex.wordpress.org/Using_Javascript at the bottom of the page for a plugin-based workaround to turn off formating for specific posts/pages, allowing you to ...


2

do_action does not return text, it just does the action. So, calling do_action( 'tribe_events_single_event_after_the_meta' ) in your do_shortcode call there will cause the iframe to be output before the shortcode.


1

You need to use the woocommerce_get_price filter: add_filter('woocommerce_get_price', 'return_custom_price', $product, 2); function return_custom_price($price, $product) { global $post, $woocommerce; // Array containing country codes $county = array('CH'); // Amount to increase by $amount = 5; // If the custromers shipping ...


0

When you are using third party themes then always create the child theme for the third party theme because they always do changes and update the theme version so it will over write all your customization in your theme. You can get help how to create child theme here https://codex.wordpress.org/Child_Themes


0

Have tried your code and it works fine and infact it also gives out the details of each product in the orders. The code which i tried $filters = array( 'post_status' => 'any', 'post_type' => 'shop_order', 'posts_per_page' => 200, 'paged' => 1, 'orderby' => 'modified', 'order' => 'ASC' ); $loop = new ...


0

Here is a reference link which you can use to try out customization in your code Let me know if this works for you in any way.


0

$arr_str = new SimpleXMLElement('<a href="www.example.com">Click here</a>'); echo $arr_str['href']; // will echo www.example.com Note that, SimpleXMLElement required PHP version above 5.


0

Here is another option to remove header and background (source): //Remove the custom options provided by the default twentyeleven theme. add_action( 'after_setup_theme','remove_twentyeleven_options', 100 ); function remove_twentyeleven_options() { remove_custom_background(); remove_custom_image_header(); remove_action('admin_menu', ...


1

For example if there are 10 custom posts, and No. 1 is the oldest, and they happened to select the 3rd oldest one, they want it to say "No. 3". There is a more elegant way than that function: $args = array( 'post_type' => 'book', 'fields' => 'ids', 'ignore_sticky_posts' => true, 'orderby' => 'post_date', 'order' => 'DESC' ...


0

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


1

The SQL you want would be: $sql = " SELECT DISTINCT post_id FROM $wpdb->posts, $wpdb->postmeta where $wpdb->postmeta.meta_value = '2015/06/03'"; $results =$wpdb->get_results($sql); But there is no reason to be involving the $wpdb->posts table at all, since the post_id value is a $wpdb->postmeta table column. $sql = " SELECT ...


0

I have zero experience with the event manager plugin.... but looking at your code; something like this might work: <?php if ( !empty( $EM_Event->event_attributes['CONTACTPHONE'] ) ) { echo $EM_Event->output('<strong>Phone:</strong> #_ATT{CONTACTPHONE}'); } ?> I'm not sure if CONTACTPHONE is the correct attribute to use in the ...


-2

I would try to display the meta using ACF like this : <?php $role = get_field('user_role', $profile_author); if( !empty($role) ): ?> <?php echo $role; ?> <?php endif; ?>


0

here is the mysql query you can use to get the result having distance less then your value. SELECT * , pm1.meta_value as latitude, pm2.meta_value as longitude , (((acos(sin(([latitude]*pi()/180)) * sin((pm1.meta_value * pi()/180)) + cos(([latitude]*pi()/180)) * cos((pm1.meta_value * pi()/180)) * cos((([longitude] - ...


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

It seems that you could use Types and Views plugins (with Views "Parametric search" feature). Views is commercial, but unless you are building your personal website, I think it's worth it. Nice writeup about those plugins is, for example, here: http://www.neilcurtis.me/guides/best-wordpress-plugins/


2

It is quite hard to properly answer your question with the amount of context in your question, but I am going to try to use the context from your previous question Having a bit more context here on template, and if I read this correctly, this is on your index.php, I still believe and stand by my point that pre_get_posts is your answer. Tackle this problem ...


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


0

This question is more of a js/jQuery is then WordPress. I am not going to post a working answer as It is hard to read the html given. And I think how you are doing it is not a effective solution. My answer should guide you towards better solution. First of all you do not need to fade in all element inside the popup. Only fade in the parent and hide the ...


1

Use Wordpress defult media uploader and get uploaded link in jquery response it is quit easy <label for="upload_image"> <input id="upload_image" type="text" size="36" name="ad_image" value="http://" /> <input id="upload_image_button" class="button" type="button" value="Upload Image" /> <br />Enter a URL or upload an ...


0

Well, when exactly do you consider the page to be "starting to load"? get_header() is typically the first function to fire as the html of a theme is starting to generated. It fires the get_header action. Numerous hooks fire prior to that, at different points, the very earliest being muplugins_loaded I believe. wp_loaded, by the way, is not when the page ...


0

You need to add overflow: hidden; to your CSS for #wpadminbar. Add this to your CSS: #wpadminbar { overflow: hidden; }


3

When you are saving the multidimensional array you can use this code: $product_img_path[$count]['wpc_resize_thumb_img'] = $upload_dir['url'].'/'.$resize_img_name; $product_img_path[$count]['wpc_resize_bid_img'] = $upload_dir['url'].'/'.$resize_big_img_name; update_post_meta($post->ID, 'wpc_images', $product_img_path); That way you can get ...


0

Try this - global $product; $categories = get_the_terms( $product->id, 'product_cat' ); and $categories will give you list of all the categories then you can check for a specific category - if(isset($categories["Test"])){ //do something } For your example - add_action( 'woocommerce_single_product_summary', 'wc_product_sold_count', 11 ); ...


0

Small changes in your code: //$id = get_the_title(); $title = '"The Man Who Wants You" – Amos Lee'; //$posttags = get_the_tags(); $posttags = array('AMOS LEE', 'FOO FIGHTERS', 'TAYLOR SWIFT'); $matched_tags = array(); if ($posttags) { foreach ($posttags as $tag) { if (stripos($title, $tag) !== false) { array_push($matched_tags, ...


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

Including a file inside a subdirectory is the same as any other as long as you know the path to the file. Since it's possible to move the 'wp-content' directory, don't pass that part of the path to the require statement; instead, use the WP_CONTENT_DIR constant. require_once WP_CONTENT_DIR . '/new-directory/my-file.php'; Also, you can leave out the ...


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.


1

yes the title will work for a file. You can use get_template_part() function to inlude your file within a wordpress template file like single.php Function Reference/get template part


0

Yes, it is quite simple, you just need to work in PHP. Consider you have 36 posts in a loop. $div_html_1 = ''; $div_html_2 = ''; $div_html_3 = ''; $div_html_4 = ''; $div_html_5 = ''; $div_html_6 = ''; if ( have_posts() ) { while ( have_posts() ) { if( category of post == division 1 ) { $div_html_1 .= "Your HTML ...


1

Put this in your loop: <?php $title = get_the_title(); $posttags = get_the_tags(); if( $title && $posttags ) { $result = find_tag_in_title( $title, $posttags ); var_dump( $result ); // dump result } ?> Put this in your functions.php file: <?php function find_tag_in_title( $title, $posttags ) { foreach( $posttags as $tag ){ ...


0

You can just use the get_option() function like this: <?php $main_dashboard_check = get_option( 'main_dashboard_check' ); var_dump( $main_dashboard_check ); /* outputs false if the value does not exist */ $main_dashboard_check = get_option( 'main_dashboard_check', 'default_value' ); var_dump( $main_dashboard_check ); /* outputs 'default_value' if the ...


1

To display monthly archives arranged by year, you can use this code. It checks through each month if WordPress have any post in that month and create archive. <?php global $wpdb; $limit = 0; $year_prev = null; $months = $wpdb->get_results( "SELECT DISTINCT MONTH( post_date ) AS month , YEAR( post_date ) AS year, COUNT( id ) as ...


0

I would do this the other way around: if ( !is_user_logged_in () ) { //the script exits if the user is not logged in require('/path/to/your/script.php'); showAccessDenied($day, $month, $year, $area, isset($room) ? $room : ""); } You can work that into a page in a number of ways. I don't have enough detail to provide an example that fits your needs.


0

Nevermind, I solved it on my own. While reading on the WordPress Codex for $wpdb, I saw that if I use OBJECT_K it will remove the duplicates and that solved my problem. If it helps anyone, here is my working code: function latest_posts_after_last_login( $atts ) { global $wpdb, $current_user; $atts = shortcode_atts( array( 'post_type' => ...


2

SOLUTION: I added $titles = array(); at the top (outside the loop). Then, within the loop, I used array_push( $titles, get_the_title( $ID ) ); to collect the titles. Then I just checked the array for a matching title before displaying, like this: if ( !in_array(get_the_title( $ID ), $titles ) ) ...then do this And it works!



Top 50 recent answers are included