New answers tagged

0

Diana you must change line of code in this array $args = array( 'exclude'=> $admin_users_list, 'number' => $limit, 'orderby' => 'registered', 'order' => 'desc', 'meta_query' => array( 'relation' => 'AND', 0 => ...


0

f you're using anything that allows you to configure SMTP within WordPress, take it out. Then put everything into a function: add_action('init','delay_until_init'); function delay_until_init(){ // call wp_mail() here }


0

The code that I finally came up with to fix the problem! <?php global $wpdb; $catresult = array(); $postid = get_the_ID(); $query1c = "SELECT wp_posts.ID, wp_terms.`name` AS `Category`, wp_pods_productcategory.`pc-url` AS `Url` FROM wp_posts INNER JOIN wp_term_relationships ON wp_posts.ID = wp_term_relationships.object_id INNER JOIN wp_terms ON ...


1

Figured it out after thinking it through.. if (stripos(strtolower($template_filename), 'home') !== false) { $results[] = $template_name; }


5

Problem "Serialization" is the act of turning a data-object into a string-representation. jQuery automatically serializes the data property before sending an AJAX request. The server then deserializes the GET querystring from the URL, and the request body for POST requests before populating PHP's request variables. Your code functioned as expected when ...


0

I think the best way to achieve what you want is to do something like so: <?php // Our custom Loop begins here $ourPosts = array( 'cat' => 317, /* Fetch your category */ 'posts_per_page' => 6, /* Display amount of posts per page */ 'orderby' => 'date', /* Order by date */ 'order' ...


1

Try <?php echo "Right sidebar".get_the_content(); ?> Don't use echo for the_content, it's already echoed out, use get_the_content instead.


0

So I finally figured it out. Using pre_get_posts and the $_GET global var to check if any query args have been added works a treat. I used the follow code to get the desired results. function my_pre_get_posts($query) { if( $query->is_main_query() && is_archive() && !isset($_GET['orderby']) && // ...


1

You should never change a core file. This message is called by the function wp_get_attachment_link(). For this singular message this function does not apply a filter, but it return the string as value, which can help. You can simple identify where in your theme this function is called and change it return, like: $result = wp_get_attachment_link(); if ...


0

Templates might load faster because they don't have to do a database query, they have already all the text hardcoded in them. Also, this might not be the right way to do it and you might have problems or conflicts if you are not doing it right. Considering the fact that the speed diference will be very small, I sugest you should go with a page created in ...


1

The delete_attachment action is fired when wp_delete_attachment() function is called to delete an item in the media library.


0

You need to override two WC templates. Create a folder woocommerce (if it doesn't already exist) under your theme's folder. From the plugins/woocommerce/templates directory copy over the files emails/plain/email-order-details.php emails/email-order-details.php and keep the same folder structure. Consult WC documentation on that one. In your versions of ...


0

If you created the taxonomy yourself, you could set your own slug for the custom taxonomy. For Example: register_taxonomy( 'productcategory', array( 'productpopups', ), array( 'labels' => array( 'name' => __('Categories', 'text-domain'), ), // --- set taxonomy slug --- 'rewrite' ...


0

Here's the relevant part of your code that should work: // This will make a URL like http://yoursite.com/path/to/fallback.png $fallback_image = site_url( '/path/to/fallback.png' ); $fallback_image = "<img src='{$fallback_image}' />"; foreach( $recent_posts as $recent ){ echo '<div class="sidebar-entries">'; $featured_image = ...


0

Update 2: <?php $storeData = []; $args = ['post_type' => 'store']; $loop = new WP_Query($args); foreach ($loop->posts as $post) { $storeData[] = [ 'title' => apply_filters('the_title', $post->post_title), 'lat' => types_render_field('lat', ['output' => 'raw']), 'long' => types_render_field('long', ...


0

You can use the cat_is_ancestor_of() function to check for child categories. http://codex.wordpress.org/Function_Reference/cat_is_ancestor_of


3

I have updated your code so that the fallback image has post permalink. I hope this helps: if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink($post->ID) . '" >'; the_post_thumbnail(); echo '</a>'; } else { echo '<a href="' . get_permalink($post->ID) . '" ><img src="'. get_stylesheet_directory_uri() . ...


1

The problem is when you are trying to get the template directory. You are getting it instead of printing bloginfo() prints the output get_bloginfo() retrieves the output So, the nice piece of code should look like this: <?php if ( has_post_thumbnail() ) { echo '<a href="' . get_permalink($post->ID) . '" >'; the_post_thumbnail(); ...


0

You need to have a <form> element. By not specifying a form action attribute the form posts to the same page you are on which makes this easy to process. Also an id on the textarea is not enough you need to add a name attribute to catch with $_POST for processing. Also adding a nonce field is good practice, and checking permissions to be safe. Try ...


0

Your rule doesn't work for custom post types because pagename is the query var specific to the page post type. Your CPT query vars are the slugs you registered them with, doujinshi_en and doujinshi_jp. You might be able to fix it by adding in additional post types via pre_get_posts: function wpd_add_custom_types( $query ){ if( ...


1

Your shortcode should look something like that function se224467_shotcode_star_rating( $atts ) { $a = shortcode_atts( array( 'grade' => 5, ), $atts ); $full_stars = floor( $a['grade'] ); // full stars $output = str_repeat( '<i class="fa fa-star"></i>', $full_stars ); // if not a whole number append a halt ...


0

I think you are looking for this- function star_rating( $atts ) { $max = 5; $atts = shortcode_atts( array( 'grade' => $max, // default ), $atts ); $star_icons = ''; $full_star = floor( $atts['grade'] ); for( $i=1; $i<=$full_star; $i++ ) { $star_icons .= '<i class="fa fa-star"></i>'; } $half_star = 0; if( (int) ...


0

There can be many reasons for that. For the beginning I'd check if the session_start() returns true, and after that I'd make sure my ajax callback function is executed. Just put some die()s in your script.


3

Sidebars are stored in global variable $wp_registered_sidebars. You can get the sidebar properties using this variable. global $wp_registered_sidebars; if ( isset( $wp_registered_sidebars['sidebar-2'] ) ) { echo $wp_registered_sidebars['sidebar-2']['name']; } Note that do not use it too early, either on/after widgets_init hook or in a template ...


-1

working code function list_post_data(){ $args="SELECT * FROM wp_posts WHERE wp_posts.`post_type` = 'post' AND wp_posts.`post_status` = 'publish'"; $args = array( 'post_type' => 'post' ); $loop = new WP_Query( $args ); $array = array(); while ( $loop->have_posts() ) : $loop->the_post(); global ...


1

Your code has many errors:- $thumbs isn't used anywhere. $img_url = $thumb['url']; undefined variable if(is_array($thumb) && $img_url) always false because of second point. $search_data = []; should be outside of loop. Check the correct part of code $search_data = []; if($query->have_posts()): while($query->have_posts()): ...


1

The use of header() function produce output in the middle of the request and crash it. To modify uploaded image you should use wp_handle_upload filter instead of save_post action. Also, ideally, you should use WP_Image_Editor class, which will use the best image manipulation library available in the server (GD, Imagemagick) and triggers several filters and ...


0

Its good practice to debug first. I mean you should check your included path root paths and other things debugging. Here I am specifying debugging steps Check file included path is correct ( by putting exit('included') ) All modules and other basic function file are included in that controller properly. Step initiate function or calling function using ...


1

Not allow. Your user is not a software developer, pretending that he is can only end bad. This is even before speaking about security etc. If you think that there are callbacks that make sense, just provide them yourself.


1

Never let anyone add any jQuery scripts via any text editor. How are you going to know if the script is malicious or not, how are you going to handle jQuery errors, how are you going to know if the jQuery is even proper and allowed jQuery. eval() brings an added extra security risk and should be avoided where user submitted strings are to be evaluated. ...


0

I just found the solution. use this code instead public function register_voguepay_woocommerce_payouts_dashboard_widget(){ add_meta_box( 'withdraw_to_bank', 'Withdraw to Bank', array($this, 'voguepay_woocommerce_payouts_dashboard_widget_display'), 'dashboard', 'side', 'high' ); } public function ...


0

Add the menu_class argument with value of cd-accordion-menu to your code, so that it looks like this: <div class="menu-container"> <nav id="site-navigation" class="main-navigation" role="navigation"> <?php wp_nav_menu(array( 'theme_location' => 'primary', 'sort_column' => 'menu_order', 'menu' => ...


0

Fixed it. function getUserIDandPush($ul){ global $table_prefix; // Prefix for Database table global $user_login; global $wpdb; // Wordpress WPDB database method $dt = $table_prefix; //Tables Prefix if (!is_user_logged_in() && isset($_SERVER['LOGON_USER'])) { $as = $wpdb->get_results('SELECT * FROM '.$dt.'users WHERE ...


0

The best approach, from my point of view, is to use add_query_arg() function: $only_conent_url = add_query_arg( array( 'content-only' => 1 ), get_permalink( $post->ID ) ); And then you can escape it if you need: esc_url( $only_conent_url ); add_query_arg() takes the URL passed as second paramenter and append a properly formatted query string ...


0

So I finally found the solution to the problem. It was in the validate.js function. I corrected the error by calling the outside functions of validate.js and jquerry: script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.4.4.min.js" script type="text/javascript" ...


-1

$WP_array = array ( 'user_login' => $username, 'user_email' => $email, 'user_pass' => $password, 'user_url' => $website, 'first_name' => $first_name, 'last_name' => $last_name, 'nickname' => $nickname, 'description' => $bio, ) ; ...


0

The error is being generated on image attachment pages, so this is most likely a bot. But I added a check before the shutter speed is converted to a fraction: $imgmeta = wp_get_attachment_metadata( $id ); $imgShutter = $imgmeta['image_meta']['shutter_speed']; // Convert the shutter speed retrieve from ...


2

shutter speed is one of the exif data wordpress tries to extract from images when uploaded. If the image do not contain the info it will be zero, hence your division by zero error. Somewhere before that code you should check if the image even needs to go there. If it is not a photo then probably not.


0

Even that you're sure that all your images have the 'shutter_speed' declared and more than 0 (although your error report is saying that some does not have), it's a good practice to validate it. Try including a new parent if like this: if ( isset($imgmeta['image_meta']['shutter_speed']) && (intval($imgmeta['image_meta']['shutter_speed'])>0) ) { ...


0

If you want the taxonomy under products post type then you must change your code from. register_taxonomy( 'manufactures', 'manufactures', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'show_admin_column' => false, 'show_ui' => true ) ); to register_taxonomy( ...


0

So, what you are trying is to add manufactures taxonomy for product post type of Woocommerce Plugin? Change manufactures object type to product and it should work. register_taxonomy( 'manufactures', 'product', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'show_admin_column' ...


0

You don't generate a WP Loop using wp_get_recent_posts() so get_the_time() won't pull the post date. The post date is available within the array wp_get_recent_posts() returns though: $recent['post_date']. Or you can use the modified date: $recent['post_modified']. This works (tested on my dev site): <?php $args = array( 'post_status' => ...


1

get_the_post_thumbnail() returns the full html output of the image, including the image <img /> tags. You want just the image src. Try this: <div class="leftBox"> <?php $query = new WP_Query( 'pagename=jour' ); // The Loop if ( $query && $query->have_posts() ) : while ( $query->have_posts() ) : ...


-2

If by 'blog page' you meant a static page set as posts page in the Reading: global $wp_query; if ( isset( $wp_query ) && (bool) $wp_query->is_posts_page ) { //static blog page } PS. This solution also works on template_redirect action


0

You can do that by by editing the template-tags.php in the inc directory. Find: sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $output_time ) Replace: sprintf( '<a class="entry-date" href="%s">%s</a>', esc_url( get_permalink() ), $regular_time ) Find: sprintf( '<a class="entry-date" ...


-1

Guess what ! it was the die() which was breaking everything. And the way I found it was totally lame(removing approx 2000 lines of code one by one). Anyways the reason makes a bit sense to me now. Thanks!


1

Wordpress errors are application level errors. PHP errors are language syntax or usage errors and appach error are errors detected during the web server operation. Errors, especially minor ones, might be reported "upwards" and look like they are wordpress application errors, or logged downwards and be part of the apache server error log if the applications ...


3

I am assuming your custom post type is also "series". Can you try this, it should work. $args = [ 'post_type' => 'series', 'posts_per_page' => -1, 'meta_query' => [ [ 'key' => 'series', 'value' => 19, 'compare' => '=', 'type'=>'NUMERIC' ] ...


1

Never edit the WordPress core files. Instead you should hook into the pre_comment_content, which is where the comment text from the textarea is being sanitized, before it's inserted into the database. In the example below preg_replace is used to sanitize the comment text submitted. You should modify the function to fit your needs. function ...


2

I guess the issue with this line: $path = "wp-content/themes/creation/templates/inc/log.txt"; You need to use the full path, not a relative part, while using fopen() or file_exists(). Something like this should fix your issue: $path = get_template_directory() . "/templates/inc/log.txt"; get_template_directory() will return the absolute server path, ...



Top 50 recent answers are included