lundi 5 octobre 2015

my wordpress site showing Out of memory error frequently

I have a WordPress site which is frequently showing out of memory error

i have also increased memory in config file

define('WP_MEMORY_LIMIT', '384M');

My php info file showing :

PHP Version 5.4.36 memory_limit 512M post_max_size 8M upload_max_filesize 4M

my error_log file showing below info. Please guide me how to resolve the issue of out of memory

[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6029312) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 2533
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 7340032) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/category-template.php on line 519
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6291456) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1029
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6553600) (tried to allocate 4480 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 3233
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 2097152) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/default-filters.php on line 108
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 9437184) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 248
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-load.php on line 56
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-load.php on line 56
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 11272192) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/media.php on line 3020
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 11534336) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1396
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4456448) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/theme.php on line 591
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 14942208) (tried to allocate 1920 bytes) in xxxxxxxx/public_html/wp-content/plugins/wordpress-importer/wordpress-importer.php on line 420
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4980736) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/user.php on line 1149
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 12320768) (tried to allocate 87 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1717
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 15990784) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/postratings-stats.php on line 424
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:02 UTC] PHP Fatal error:  Out of memory (allocated 20447232) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_utility.php on line 352
[05-Oct-2015 02:05:02 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so: failed to map segment from shared object: Cannot allocate memory in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 18874368) (tried to allocate 3840 bytes) in xxxxxxxx/public_html/wp-content/themes/hdwallpapers/functions.php on line 221
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 15466496) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/wp-postratings.php on line 464
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 15990784) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/postratings-stats.php on line 424
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 18612224) (tried to allocate 32 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 620
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 9600 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1526
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 14942208) (tried to allocate 1920 bytes) in xxxxxxxx/public_html/wp-content/plugins/wordpress-importer/wordpress-importer.php on line 420
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/widgets.php on line 1391
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 13107200) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/ewww-image-optimizer/common.php on line 493
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 8650752) (tried to allocate 33280 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 733
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1600
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 12582912) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/ewww-image-optimizer/ewww-image-optimizer.php on line 511
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 11010048) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/canonical.php on line 264
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 6815744) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 4961
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 1835008) (tried to allocate 690 bytes) in xxxxxxxx/public_html/wp-includes/wp-db.php on line 2146
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 12320768) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1714
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 9175040) (tried to allocate 4480 bytes) in xxxxxxxx/public_html/wp-includes/deprecated.php on line 2223
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 6291456) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 993
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 2883584) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 183
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3145728) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 1158
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 5767168) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 141
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4194304) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/query.php on line 2794
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3670016) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/capabilities.php on line 1235
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3407872) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 3166
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4980736) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/user.php on line 1300
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 2883584) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 183
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1579
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8650752) (tried to allocate 33280 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 733
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 8960 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1518
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 9699328) (tried to allocate 79360 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 532
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 9437184) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 248
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1579
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 244
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 6029312) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 2524
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 19660800) (tried to allocate 32 bytes) in xxxxxxxx/public_html/wp-includes/functions.php on line 1602
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 18087936) (tried to allocate 640 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_module_class.php on line 597
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 17825792) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 2863
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 18612224) (tried to allocate 89 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 612
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 19922944) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/template-loader.php on line 48



via Chebli Mohamed

Disable Garbage Collection?

I have a WP site which creates 500's errors for about 2% of Apache requests (mostly bots and crawlers). I'm not able to stack trace most of those requests with 500's neither to PHP or MySQL errors.

Is it good idea to disable a garbage collection (gc_disable()) for the whole WP site to prevent any memory leak caused by a theme or plugins?



via Chebli Mohamed

I want login using email not username wordpress front end

I want login using email not username wordpress front end

remove_filter('authenticate', 'wp_authenticate_username_password', 20);
function login_with_email_address($username) {
    $user = get_user_by_email($username);
    if(!empty($user->user_login))
        $username = $user->user_login;
    return $username;
}
add_action('wp_authenticate','login_with_email_address');



via Chebli Mohamed

Wordpress SMS API integration without plugin

I am struggling with SMS sending in WordPress without plugin, I have a, API, but that API is not working. Example:

function mysite_woocommerce_order_status_processing( $order_id ) {

$mobile="123456";

$url="****/api.php?username=******&password=1234&source=UPDATE&dmobile=".$mobile."&message='.$msg.' ";

$response = wp_remote_get( $url ); //print_r($response);

} add_action( 'woocommerce_order_status_processing','mysite_woocommerce_order_status_processing' );

I am struggling with above hook, I can send Email through that hook, but not SMS. It would be great if any WordPress developer help me out !

Getting SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data



via Chebli Mohamed

Is there a way to optimize function that is used for returning data in an ajax-call?

I've started creating some plugins (not offically deployed yet) (feel free to use it you want to), and now my goal is to include a custom post type and taxonomy and being able to use Advanced Custom Fields if wanted. The purpose of the plugin is to create a list based on custom taxonomy / custom post types and being able to put that anywhere on any page (with a shortcode) and when selecting anything from that list fetch content from the selected custom post type) and put it into another div without page reload.

This is my code (forgive the swedish part, but it's not neccessary I think for the actual question):

<?php
/*
Plugin Name: ListAjax
Plugin URI: http://ift.tt/1VAqyY1
Description: Display a list and display returned content (from ajax-call) into a div
Version: 0.8.0
Author: Wibergs Web
Author URI: http://ift.tt/1MVBmIx
License: GPL
Copyright: Wibergs Web
*/
defined( 'ABSPATH' ) or die( 'No access allowed!' );

if( !class_exists('listajax') ) {

class listajax
{
    private $errormessage = null;


    /*
    *  Constructor
    *
    *  This function will construct all the neccessary actions, filters and functions for the listajax plugin to work
    *
    *
    *  @param   N/A
    *  @return  N/A
    */  
    public function __construct() {                        
        //These are needed and should only register custom post types when really neccessary
        register_activation_hook( __FILE__, array( $this, 'activate' ) );                        
        add_action( 'init', array( $this, 'register_post_types' ) );

        //Iniate jquery and css
        add_action( 'wp_enqueue_scripts', array($this, 'js_css' ) );                             
    }


    /*
     *  error_notice
     * 
     *  This function is used for handling administration notices when user has done something wrong when initiating this object
     *  Shortcode-equal to: No shortcode equavilent
     * 
     *  @param N/A
     *  @return N/A
     *                 
     */                 
    public function error_notice() {
            $message = $this->errormessage;
            echo "<div class=\"error\"><strong>ListAjax error:</strong><p>$message</p></div>"; 
    }


    public function activate() {
            $this->register_post_types();
            flush_rewrite_rules(); 
    }


    /*
     *  register_post_types
     * 
     *  This function register post types and taxonomies
     * 
     *  @param N/A
     *  @return N/A
     *                 
     */                    
    public function register_post_types() {
        $municipality_labels = array(
              'name' => 'Kommun',
              'singular_name' => 'Kommun',
              'add_new' => 'Lägg till',
              'add_new_item' => 'Lägg till ny kommun',
              'edit_item' => 'Redigera kommun',
              'new_item' => 'Ny kommun',
              'all_items' => 'Alla kommuner',
              'view_item' => 'Visa kommun',
              'search_items' => 'Sök kommuner',
              'not_found' => 'Inga kommuner funna',
              'not_found_in_trash' => 'Inga kommuner funna i sopkorgen',
              'parent_item_colon'  => '',
              'menu_name' => 'Kommuner'
            );
            $municipality_args = array(
              'labels' => $municipality_labels,
              'public' => true,
              'publicly_queryable' => true,
              'show_ui' => true,
              'show_in_menu' => true,
              'query_var' => true,
              'rewrite' => array( 'slug' => 'kommun' ),
              'capability_type' => 'post',
              'has_archive' => 'kommuner',
              'hierarchical' => false,
              'menu_position' => null,
              'supports' => array('title','editor','author','comments'),      
            );
            register_post_type( 'municipality', $municipality_args );


            //Register custom taxonomy for distict
            $district_cat_labels = array(
              'name' => 'Område',
              'singular_name' => 'Område',
              'search_items' => 'Sök område',
              'all_items' => 'Alla områden',
              'parent_item' => 'Område - förälder',
              'parent_item_colon' => 'Föräldra område:',
              'edit_item' => 'Redigera område',
              'update_item' => 'Uppdatera område',
              'add_new_item' => 'Lägg till nytt område',
              'new_item_name' => 'Namn på nytt område',
              'menu_name' => 'Områden'     
            );
            $district_cat_args = array(
              'hierarchical' => true,
              'labels' => $district_cat_labels,
              'show_ui' => true,
              'show_admin_column' => true,
              'query_var' => true,
              'rewrite' => array('slug' => 'omraden')
            );
            register_taxonomy( 'district', array('municipality'), $district_cat_args );                        
    }

    /*
     *  init
     * 
     *  This function initiates the actual shortcodes (at each pageload)
     * 
     *  @param N/A
     *  @return N/A
     *                 
     */        
    public function init() {                           
        //Add shortcode
        add_shortcode( 'lajax-show', array($this, 'show') );
        add_shortcode( 'lajax-contactinfo', array($this, 'show_contactinfoblock') );

        //Initate ajax-functionality
        add_action( 'wp_ajax_set_contactinfo', array ( $this, 'set_resultdiv') );
        add_action( 'wp_ajax_nopriv_set_contactinfo', array ( $this, 'set_resultdiv') );
    }



    public function set_resultdiv() {                    
        $post_id = $_POST['post_id'];
        $post_info = get_post($post_id, ARRAY_A); //Array for better performance
        $post_content = $post_info['post_content']; //If there any content in post , then show this first

        $html .= $post_content;                        

        //If using ACF (Advanced Custom Fields plugin) with get_fields()-function
        if( function_exists( 'get_fields' ) ) {                            
            $fields_cpt = get_fields($post_id);

            if (is_array($fields_cpt)) {

                //Loop through fields of current post
                foreach($fields_cpt as $field_key => $field_value) {
                        //If field value starts with http, then take for granted it should be linked
                        if (substr($field_value, 0,4) === 'http') {
                                $new_fieldvalue = '<a target="_blank" href="' . $field_value . '">' . $field_value . '</a>'; 
                        }
                        else {
                                $new_fieldvalue = $field_value; //"Normal" value
                        }

                        //Get the label that user has typed in administration
                        $field = get_field_object($field_key, $post_id, array('load_value' => false));                                                        
                        $label = $field['label'];

                        //Do the actual output of each label and value 
                        //that is defined in ACF for the custom post type
                        $html .= '<span class="lajax-wrapper">';
                        $html .= '<span class="lajax-title">' . $label. '</span>';
                        $html .= '<span class="lajax-value">' . $new_fieldvalue . '</span>';
                        $html .= '</span>';
                }
            }              

        }

        echo $html;                        
        wp_die();
        return;
    }                

    public function js_css() {                       
       wp_enqueue_script(
               'listajaxjs',
               plugins_url( '/js/wibergsweb.js' , __FILE__)
       );                          
   }            

    public function show_contactinfoblock() {
        $html = '<div class="lajax-container">';
        $html .= '<div id="contactinfo"></div>';
        $html .= '</div>';
        return $html;
    }

    /*
     *  show
     * 
     *  This functions shows a list  based on a taxonomy (that is identified by slug)
     * 
     *  @param N/A
     *  @return string      date
     *                 
     */      
    public function show( $attrs ) {
        $defaults = array(
                'slug' => null, //Must be set by user!
                'result_div' => '#contactinfo'
        );                        

        //Extract values from shortcode and if not set use defaults above
        $args = wp_parse_args( $attrs, $defaults );
        extract( $args ); //slug = $args{'slug'] etc

        //Validation
        if ($args['slug'] === null) {
                $this->errormessage = 'Slug of district must be set - show()';
                add_action( 'admin_notices', array( $this,'error_notice' ) ); 
                return;
        }

        //Get posts of selected municaplity
        $posts_array = get_posts(
            array(
                'posts_per_page' => -1,
                'post_type' => 'municipality',
                'tax_query' => array(
                    array(
                        'taxonomy' => 'district',
                        'field' => 'slug',
                        'terms' =>  $args['slug']
                    )
                )
            )
        );

        //Create the actual selectlist based on selected district
        $result_div = $args['result_div'];

        $html = '<form name="ajaxlistform" class="ajaxlistform">';
        $html .= '<select class="ajaxlist" data-resultdiv="' . $result_div . '">';
        foreach($posts_array as $pa) {
            $id = $pa->ID;
            $title = $pa->post_title;
            $html .= '<option value="' . $id . '">' . $title . '</option>';                            
        }
        $html .= '</select></form>';

        return $html;             
    }

}        
$listajax = new listajax();
$listajax->init(); //Execute AFTER user defined settings are set
}

The result_div() - function is returning data to the javascript:

jQuery(function ($) {
    //Ajax-retrieve value from selected custom post type (that is shown in list)          
    $('.ajaxlistform').on('change', '.ajaxlist', function(e) {   
       var t = $(this);
       var post_id = $(this).val();  //Value from selectlist

        var listajaxvalues = $.ajax({            
            type: 'POST',
            data:{
                action: 'set_contactinfo',    
                post_id: post_id
            },
            url: '/wp-admin/admin-ajax.php',
            dataType: 'html'
        });

        //Put data into resultdata div that is set inte data-resultdiv attribute
        listajaxvalues.done(function(data) {
                var result_data = t.data('resultdiv');
                $(result_data).html(data);
                return;
        });                        

        listajaxvalues.fail(function(ts) {           
            alert(ts.responseText);
       });


    });

});

Is there a way to optimize (in terms of speed) the result_div() - function? It takes about a second to retrieve information. It does not sound like a lot of time, but when selecting from the selectlist, it seems like forever ;-)



via Chebli Mohamed

How to get popular post tags

I need to get post popular tags. Here what I found from http://ift.tt/1MVBmsj

$tag = wp_tag_cloud( 'smallest=8&largest=22&number=2&orderby=count&format=array' );

Here is an example from Wordpress site:

Cloud displayed under Popular Tags title

<?php if ( function_exists( 'wp_tag_cloud' ) ) : ?>    
<h2>Popular Tags</h2>
<ul>
<li><?php wp_tag_cloud( 'smallest=8&largest=22' ); ?></li>
</ul>    
<?php endif; ?>

I did not understand this parameters meaning smallest=8&largest=22 and does this example what I need?



via Chebli Mohamed

Give me some opinion about this theme!

Can anyone give me some suggestion about the the name of this theme or something like that on http://min.st319.vn ? Thank you so much!!!



via Chebli Mohamed

Send email to different users depending on the field selected in woocommerce?

So, I've been searching high and low and I don't know if this is possible, but I figure this is the best place to try and see..

I have a checkout field added to my checkout page in woocommerce. It works great, the fields show up in the emails.

However, what I was hoping was that I could get it so that the emails could be sent out to various addresses depending on what field they chose... is that possible?

For example, if someone chose "contractor a" in a checkout page email, I would then want it to send to the woocommmerce admin (which it already does) AND contractoremail@email.com.

PLEASE let me know if any one has any ideas. I would greatly appreciate it.



via Chebli Mohamed

Access methods in plugin template

I'm new to PHP and trying to learn my way through Wordpress. Within my theme's functions.php file, I wanted to access a method available inside bbPress's plugin template.php file. I'm getting "Unexpected token ['

Inside bbPress plugin template.php:

function bbp_topic_reply_count( $topic_id = 0, $integer = false ) {
    echo bbp_get_topic_reply_count( $topic_id, $integer );
}

I'm accessing this function in my current theme's functions.php:

$count = bbp_topic_reply_count(125);

Do I have to include anything from the plugin (i.e bbpress/template.php)?

Thanks.



via Chebli Mohamed

Cannot change hover color for links

I am using twentytwelve and a child theme at http://ift.tt/1VA80aj.

I would like all links in my website to have this dark blue color on hover: #0f3647

The only links where this color is working is the post titles. These links, however, stay #21759b on hover no matter what I try:

  • After a post, the links for "Continue reading" and "X Replies"
  • The links under the "Recent Posts" widget on the right
  • The "Reply" links in the comment area under a post

Below is the exhaustive list I've tried adding to my child theme's style.css, and none of them have any effect. Somewhere, deep the soul-sucking abyss of CSS, the hover property is being overridden.

I tried a giant hammer:

a:hover {
    color: #0f3647 !important;
}

And I tried these (where #0fs647 is #21759b in the parent):

For "Continue reading" and "X Replies":

.more-link a:hover {
    color: #0f3647;
}

.leave-reply a:hover { 
    color: #0f3647;    
}

.reply-count a:hover {
    color: #0f3647;  
}

For the Recent Posts widget:

.widget-area .widget a:hover {
    color: #0f3647;
}

For the "Reply" in the comments area:

.comments-link a:hover {
    color: #0f3647;
}

I also tried:

.site-header h1 a:hover,
.site-header h2 a:hover {
    color: #0f3647;
}

.main-navigation a:hover,
.main-navigation a:focus {
    color: #0f3647;
}

Any suggestions?



via Chebli Mohamed

Making menu link open in new tab?

I'm trying to add a top level menu to the left sidebar of the WordPress admin panel.

Here's the code I currently have:

add_action( 'admin_menu', 'linked_url' );
function linked_url() {
add_menu_page( 'linked_url', 'Menu Title', 'read', 'my_slug', '', 'dashicons-text', 1 );
}

add_action( 'admin_menu' , 'linkedurl_function' );
function linkedurl_function() {
global $menu;
$menu[1][2] = "https://www.example.com";
}

This code DOES work and links the menu to an external page (https://www.example.com).

I learned how to do this from here: http://ift.tt/1OUiBbT

However, I can't figure out how to make the external link open in a new tab. I'd prefer than a new tab/window is opened so people don't lose what they already have open in their admin area.

Is there something I need to change or add? Or is it just not possible?



via Chebli Mohamed

Changing post status with js

I'm having issues grabbing some actions inside a navigation menu..

So it's going like this(for the publish button) HTML

 <a href="javascript:updatepost()" class="menu-item fa fa-facebook">Save</a>

 <script>
    function updatepost()
        {
          jQuery('#publish').click();
        };
 </script>

What i can't find tho it's to do the same(or something similar) for the "Move to Trash" and change the post status to 'pin_featured'

Any guidance it's much apreciated!



via Chebli Mohamed

Downloading File from Outside Web Root

I've set up some code to download zip files that exist in a folder above the web root. The download will be triggered from a user account page within WordPress. They don't need to be bank-level secure, but I'd like to prevent direct file access from outside the site and make them accessible only for users with the correct permission levels, and only from the appropriate user's account page. The site is entirely https.

The folder where the zip files reside is protected via htaccess.

Each user that's assigned to a specific user role will see a download link on their "Account" page:

if(current_user_can('download_these_files')){
    $SESSION['check'] = 'HVUKfb0IG1HIzHxJj5fZ';
    ?>
        <form class="user-file-download-form" action="/download.php" method="POST">
            <input type="submit" name="submit" value="Download File">
        </form>
    <?php
}

This form submits to download.php, which sits in the web root and includes some code that I've pieced together with help from Google.

session_start();
if( isset( $_POST['submit'] ) ){
    $check = $_SESSION['check'];
    if( $check === 'HVUKfb0IG1HIzHxJj5fZ' ){
        $file = /path/to/file/above/root.zip;
        header('Content-Description: File Transfer');
        header('Content-Type: application/zip');
        header('Content-Disposition: attachment; filename=' . basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file));
        ob_clean();
        flush();
        readfile( $file );
        exit;
    }else{
        header( 'Location: http://ift.tt/1L3fW9F' );
}else{
    header( 'Location: http://ift.tt/1L3fW9F' );
}

This works perfectly. But I can't help but wonder if I should be doing something differently. I was hoping to get input on whether or not this implementation is prodcution-ready, or if I'm missing something important as this is the first time I'm attempting something like this.

Thank you.



via Chebli Mohamed

What would Repair and Optimize Wordpress Database do?

Recently I am getting an error establishing a database connection in a clients Wordpress site. I googled for a solution and an article suggested to enable Wordpress Repairs by adding this to the wp-config.php file:

define('WP_ALLOW_REPAIR', true);

After that, visit the link:

http://ift.tt/1ab1nSy

And allowing repair as follow:

WordPress Database Repair Tool UI

So my question is. What does optimization mean? What are those scenarios or situations that Wordpress fix? Can I do this procedure in existing and non problematic Wordpress websites to enhance performance?



via Chebli Mohamed

How to force acceptance of site terms on first login?

I want to force users to accept the terms and conditions of the site when they log in for the first time. I found a couple plugins that would show the terms, but they don't prevent you from ignoring the form and moving on to other site pages. Is there a way to prevent the user from going anywhere until they have accepted the terms?



via Chebli Mohamed

Wordpress loop, most recent post from multiple category in custom category order?

I have a site with posts in 16 categories ("departments"). The home page is a grid of the current (newest) post in each category.

I would like to create the HTML for displaying a department's current post and use a word press loop to repeat this 16 times to get the grid.

ALSO - and her is the part I need help with - the client wants to specify the categories AND the order they appear.

So, my page is the newest post from "Dining", then the newest from "travel", etc.

Here's the site currently where the previous designer did this by hand in a table every month, which is silly.



via Chebli Mohamed

Can someone tell me where I've gone wrong with this plugin's Settings page?

I've been trying to learn how to make a plugin in my spare time. I'd previously done all of the coding pertaining to the settings page and it all appeared to work well. Having completed some other parts of the test plugin I returned (a few weeks later) and now when I save adjustments to the settings I get shown a long list of database field names with associated input/textarea values returned but adjustments are not saved. I'm confident that nothing else is using add_action('admin_menu/admin_init')

The plugin is built as a class. Here's all the code relating to the settings page

class rifh_tester{

 public function __construct(){
  /* admin */
  if(is_admin()){
   add_action('admin_menu', array($this, 'settings_add_menu'));
   add_action('admin_init', array($this, 'settings_admin_init'));
  }
 }

 public function settings_add_menu(){
  add_options_page('RifH Tester Settings', 'RifH Tester', 'manage_options', 'rifh_tester', array($this, 'settings_opts_page'));
 }

 public function settings_opts_page(){
  echo '<div id="rifh-tester-setup"><form action="options.php" method="post">
       ' . settings_fields("rifh_tester_options") . do_settings_sections("rifh_tester") . '
       <input name="submit" type="submit" value="Save Changes">
       </form>
       </div>';
 }

 public function settings_admin_init(){
  register_setting('rifh_tester_options', 'rifh_tester_options', array($this, 'rifh_tester_options_validate'));
  add_settings_section('rifh_tester_options_main', __('Welcome to the RifH Tester Setup Page'), array($this, 'rifh_tester_options_text'), 'rifh_tester');
  add_settings_field('rifh_tester_option_image_generate', __('Test Creating An Image?'), array($this, 'rifh_tester_option_image_generate'), 'rifh_tester', 'rifh_tester_options_main');
  add_settings_field('rifh_tester_option_image_limit', __('Test Define An Image Size'), array($this, 'rifh_tester_option_image_limit'),  'rifh_tester', 'rifh_tester_options_main');
  add_settings_field('rifh_tester_option_appears_on', __('Where Should Test Images Show?'), array($this, 'rifh_tester_option_appears_on'),  'rifh_tester', 'rifh_tester_options_main');
  add_settings_field('rifh_tester_option_image_type', __('Preferred Format For Test Images?'), array($this, 'rifh_tester_option_image_type'), 'rifh_tester', 'rifh_tester_options_main');
 }

 public function rifh_tester_option_image_generate(){
  echo "<label><input id='rifh_tester_option_image_generate' name='rifh_tester_options[image_gen]' type='checkbox' ".($this->options['image_gen'] ? 'checked>Yes' : '>No')."</label>";
 }

 public function rifh_tester_option_image_limit(){
  echo "<label><input id='rifh_tester_option_image_limit' name='rifh_tester_options[image_lim]' type='text' value='{$this->options['image_lim']}'> Width of each Linky box in pixels.</label>";
 }

 public function rifh_tester_option_appears_on(){
  echo "<label><input id='rifh_tester_option_appears_on' name='rifh_tester_options[single]' type='checkbox' ".($this->options['single'] ? "checked>Yes" : ">No")."</label>";
 }

 public function rifh_tester_option_image_type(){
  $html = "<select id='rifh_tester_option_image_type' name='rifh_tester_options[image_type]'>";
  $values = array('png','jpg','gif');
  foreach($values as $format){
   $html .= "<option value='$format'";
   if($format == $this->options['image_type']){
    $html .= " selected";
   }
   $html .= ">$format</option>";
  }
  $html .= "</select>";
  echo $html;
 }

 public function rifh_tester_options_validate($input){
  $newinput = array();
  $newinput['image_gen'] = false;
  if(isset($input['image_gen'])){
   $newinput['image_gen'] = true;
  }

  if(isset($input['image_lim']) && preg_match('#^([1-9]([0-9]{1,2})?|1000)$#', $input['image_lim'])){
   // I've excluded private isFloat function as it's a basic function of the class
   if($this->isfloat($input['image_lim'])){
    $input['image_lim'] = round($input['image_lim'], 4);
   }
   $newinput['image_lim'] = $input['image_lim'];
  }

  if(isset($input['image_type']) && preg_match('#^(jpg|png|gif)$#', $input['image_type'], $match)){
   $newinput['image_type'] = $match[1];
  }

  $newinput['single'] = false;
  if(isset($input['single'])){
   $newinput['single'] = true;
  }
  return $newinput;
 }

 public function rifh_tester_options_text($args){
  echo "<div id='{$args['id']}'></div>";
 }
}

When I actually look at the HTML generated on the settings page it appears also that the <form> appears after all the fields and only has a Submit input. Making me think that the error is with the settings_opts_page function defined in the class but I can't see what it would be.

I've re-read all the guidance I can find on the Settings-API for WP, I can't understand what I'm doing wrong. Can anyone point me in the right direction?



via Chebli Mohamed

wpmu_new_user hook not firing

I have a WP Multisite setup with woocommerce on each of the sites. I am trying to hook into wpmu_new_user to send customer info to our CRM when they register at the checkout.

add_action('wpmu_new_user', 'send_to_crm',10,1);
function send_to_crm($user_id) {
    //function sends data to CRM, have tested this works by placing code direct into functions.php with hard coded $user_id variable
}

With this added to my child theme's functions.php and going through the checkout process nothing is submitted to the CRM but the order goes through as normal.

So a couple of questions: 1. Is this the right hook to use? 2. If yes, is there something wrong with my code?

Thanks in advance!



via Chebli Mohamed

WC - change From email only in the new order email

I want to change the From email when email about a new order is sending in WooCommerce. I know that I can use wp_mail_from filter but my issue is that I don't know how to determine that the WC_Email_New_Order email is sending and not some other one.

I tried something like this:

function prefix_set_from_email( $email ) {
    $mailer = WC()->mailer();
    $new_order_email = $mailer->emails['WC_Email_New_Order'];
    if ( null !== $new_order_email->object && is_email( $_POST['billing_email'] ) ) {
        $email = $_POST['billing_email'];
    }
    return $email;
}
add_filter( 'wp_mail_from', 'prefix_set_from_email', 50 );

But it change the address when WC_Email_Customer_Completed_Order email is sending too. Any advice? :)



via Chebli Mohamed

Remove Categories and Tags from Admin Dashboard

I'm using my own taxonomy for blog posts and would like to remove Categories and Tags from the Dashboard. I've removed them from the Admin Menu and the meta boxes on the Edit Posts page from this question here: Remove Categories / Tags From Admin Menu

But now I'm trying to remove it from the All Posts page in the Dashboard where it shows a list of all the posts in a table and across the top are Title, Author, Categories, Tags, Date, etc. I can't seem to find how to do this.



via Chebli Mohamed

How to create a custom email signup form?

I'm using jquery blockui to show a newsletter modal on frontpage and I already have the form, so I need to know how to insert that email as a new subscriber in WP, I mean, what is the php code to make the insertion properly?

I will need to get the response using ajax (the code should be return "done" or "failed" or some stuff like that.

Any help?



via Chebli Mohamed

WP REST API v2. filters doesn't work

I'm using WP REST API v2 to get posts.

When I tried to open localhost/wp-json/wp/v2/posts in my browser I got json with all my posts.

I tried to open localhost/wp-json/wp/v2/posts/?category_name=uncategorized and I got the same json though all my posts assigned to specific categories.

Maybe I'm using wrong filter but I tried to open localhost/wp-json/wp/v2/media?post_parent=15 from first json and got all media on my site instead of one attached to the post

What I'm doing wrong with this?



via Chebli Mohamed

Creating a News Display

Im looking to display latest articles from the BBC News site in a gallery style layout on my site with two rows and a responsive number of columns, with the article photo as the thumbnail and article heading beneath it which is a clickable link to head straight to BBC News site. Does anyone know how I can achieve this?

I know they have an RSS feed but I can't find a way to display it as described (or similarly above) and any tips would be gratefully received.

Thanks.



via Chebli Mohamed

Set all post with X category to X post format when using XML-RPC

I came across this thread, which seems like it would work for what I'm trying to accomplish. I'm a little unclear on this code and was hoping for a hand. When a post is submitted to my wordpress site via XML-RPC integration with a specific category, I want to the post to default to a specific post format.

Do I simply change out the "aside" format for my desired format, and change 'tweet' for my desired category?

<?php

/* Plugin Name: WPSE53245 - Set Tweet category posts as Aside Plugin URI: http://http://wordpress.stackexchange.com/questions/53235 Description: Set Tweet category posts as Aside Version: 0.1 Author: Ashfame Author URI: http://ift.tt/1MUGf4G */

add_action( 'save_post', 'wpse53235_set_post_format_aside' );

function wpse53235_set_post_format_aside( $postID ) {
    if ( has_post_format( 'aside', $postID ) || !has_term( 'tweet', 'category', $postID ) )
        return;
    set_post_format( $postID, 'aside' );
}



via Chebli Mohamed

WP Query using Advanced Custom Fields data

I have a page 'Repertoire' that uses a specific page template. The page has an advanced custom fields repeater field for 'Title' (text), 'Artist' (text) and 'Genre' (select). On the front end, I need the titles to be displayed by genre, with the genre used as a heading for each section. I know I need to do a WP_Query, but do not know where to start with it.



via Chebli Mohamed

How to add custom taxonomy slug in CPT permalink?

This is the code i have until now to add a CPT articles and taxonomy articles-category.

The code works, sort off. The pages are displaing correct (when i access them directly):

articles/

articles/categ-slug/

articles/categ-slug/post-slug/

The problem appears when the permalink are generated automatically (eg: yoast breadcrumbs)

<span typeof="v:Breadcrumb">
<a href="example.com" rel="v:url" property="v:title">Example</a> /
<span rel="v:child" typeof="v:Breadcrumb"><a href="http://ift.tt/1j9PLY0" rel="v:url" property="v:title">Articles</a> /
<span rel="v:child" typeof="v:Breadcrumb"><a href="http://ift.tt/1VBOXH8" rel="v:url" property="v:title">Category name</a> /
<span class="breadcrumb_last">Post Name</span></span></span></span>

Notice http://ift.tt/1q0pU4q%articles-category%/ where it should be just http://ift.tt/1q0pU4q

What is wrong in the code and how can i make it work?

function custom_post_articles() {

    $labels = array(
        // labels
    );

    $args = array(
        'labels'        => $labels,
        'public'        => true,
        'menu_position' => 5,
        'supports'      => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
        'has_archive'   => true,
        'hierarchical'  => true,
        'rewrite'       => array('slug' => 'articles/%articles-category%','with_front' => false),
        'query_var'     => true,
        //'rewrite'     => true,
        //'publicly_queryable' => false,
    );
    register_post_type( 'articles', $args );
}
add_action( 'init', 'custom_post_articles' );


function my_taxonomies_product() {
    $labels = array(
        //labels
    );
    $args = array(
        'labels' => $labels,
        'hierarchical'  => true,
        'public'        => true,
        'query_var'     => 'articles-category',

        'rewrite'       =>  array('slug' => 'articles' ),
        '_builtin'      => false,
    );
    register_taxonomy( 'articles-category', 'articles', $args );
}
add_action( 'init', 'my_taxonomies_product', 0 );

add_filter('post_link', 'articles_category_permalink', 1, 3);
add_filter('post_type_link', 'articles_category_permalink', 1, 3);

function articles_category_permalink($permalink, $post_id, $leavename) {

    if (strpos($permalink, '%articles-category%') === FALSE) return $permalink;
        // Get post
        $post = get_post($post_id);
        if (!$post) return $permalink;

        // Get taxonomy terms
        $terms = wp_get_object_terms($post->ID, 'articles-category');
        if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0]))
            $taxonomy_slug = $terms[0]->slug;
        else $taxonomy_slug = 'no-category';

    return str_replace('%articles-category%', $taxonomy_slug, $permalink);
}



via Chebli Mohamed

Simple Geo targeting

I would like some very simple and limited Geo targeting functionality.

I want to display a different footer depending on whether the visitor is from US or not. Ideally the code should be something like this:

<?php if ( visitor is from usa ): ?>
<?php get_footer('us'); ?>
<?php else: ?>
<?php get_footer('other-countries'); ?>
<?php endif; ?>

I would prefer the solution to be as simple and light as possible.



via Chebli Mohamed

Make site responsive

I have made a lot of changes to the website since my last question. However I have one last thing that I have been struggling with. The theme seems to have very little/poor support for different screen sizes. Does anyone know of any plugins that could possibly be installed to allow me to quickly make the site responsive without having to hard code it in the CSS?

I have searched on YouTube for any plugins that can do this and I cannot seem to find any.

Thanks in advance

Courtney



via Chebli Mohamed

Dropdown menu - hide selected item

function choose_ashtopbar() {
    $html = <<<HTML
<div class="dmzeus">
    <ul>
        <li class="f-selection">London
            <ul>
                <li class="f-newyork">New York</li>
                <li class="f-paris">Paris</li>
                <li class="f-london">London</li>
                <li class="f-milan">Milan</li>
            </ul>
        </li>
    </ul>
</div>
HTML;

    return $html;
}

I am using the above function to select cities from a dropdown menu.

However, the selected city needs to be hidden from the menu using javascript, I presume. In my example .f-london should have css display:none;



via Chebli Mohamed

All pages showing same posts

My blog is showing all the same posts (recent 10) on every paginated page. I'm trying to get it to display only the category "irl", which is working. but /page/2 etc. show the same posts..

my loop:

  <?php get_header(); ?>
<div id="content">
    <div id="main-content">
        <?php query_posts( 'category_name=irl&showposts=10'); while (have_posts()) : the_post(); // ?>
<b>
<div id="min-thumb" style="margin-bottom:80px;">
<?php 
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    the_post_thumbnail();
} 
?>
</div>

<a style="display:none;" href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>

<?php
endwhile;
?>

        </div><!-- close:main-content -->
        <?php get_sidebar(); ?>
    </div><!-- close:content -->
<?php get_footer(); ?>



via Chebli Mohamed

WP 4.3.1 new install on localhost missing php.ini

I've installed WordPress on my localhost Mac OSX Yosemite box. I'm getting error:

The uploaded file exceeds the upload_max_filesize directive in php.ini

phpinfo() reports upload_max_filesize = 2M

I noticed that there was no php.ini inside the wp-admin folder of the WordPress default install, so I placed one there with upload_max_filesize = 64M.

I placed the php.ini into the wp-admin directory of the site I'm working. Unfortunately, I still get the error message. And phpinfo() file located in root directory of the site still reports upload_max_filesize = 2M

Any ideas how to resolve? The only other php.ini file I have is under:

private/etc/php.ini.default

I've edited that one to 64M as well, but no change in phpinfo() still.

The WP install is a brand new zip of 4.3.1 from wordpress.org



via Chebli Mohamed

Wordpress, add post to custom taxonomy's category

I am trying to add a post to a category under taxonomy cate. The code I am using is:

$user = get_user_by( 'email', $_POST['user'] );
$id = array(
    'post_title'    => $_POST['title'],
    'post_content'  => $_POST['content'],
    'post_date'     => date('Y-m-d H:i:s'),
    'post_author'   => $user->ID,
    'taxonomy' => ('cate'),
    'post_type'     => 'ad',
    'post_category' => array(425),
    'post_status'   => 'publish',
); 
 $user_id = wp_insert_post($id);
if ( ! is_wp_error( $user_id ) ) {
   $odgovor["success"] = 1;

}

The post is added but it's added under category 'uncategorized" and not under desired category ID. This system works properly when custom post type is not used. (In this case taxonomy 'cate')

Any ideas?



via Chebli Mohamed

Failed to connect to PC:21 - WordPress & XAMPP

I've searched the XAMPP and Apache sites and can't seem to find anyway with the same problem that I'm having which includes an answer that'll work for my system.

I'm using a Macbook and have installed XAMPP so I can have a local environment for WordPress development. Problem is, is that when I try to do anything like updates, WordPress is asking for FTP details. Something I've never even seen before until now.

So I enter the host, username and password. It seems to be correct but says the following "Failed to connect to FTP Server My Mac:21".

Does anyone know how to fix this? I'm assuming port 21 is blocked or something? But I have no idea how to go about fixing it. Thanks.



via Chebli Mohamed

Looping Through Custom Tax Terms and Displaying All Posts For Each

I'm using the following code to attempt to loop through each of the terms within my custom taxonomy category-film and then output the term name as a heading together with displaying all the custom posts that belong to that term

<?php $terms = get_terms( 'category-film' ); ?>

<?php foreach( $terms as $term ) : ?>

    <?php $posts = new WP_Query( 'post=film&category-film= ' . $term->slug . '&posts_per_page=-1' ); ?>

    <?php if( $posts->have_posts() ): while( $posts->have_posts() ) : $posts->the_post(); ?>        

        <h3><?php echo $term->name; ?></h3>
        <p><?php the_title(); ?></p>

        <div class="col-md-6">
            <?php the_field('url'); ?>
        </div>  

    <?php endwhile; endif; ?>

<?php endforeach; ?>

I am finding, however, that my code outputs nothing whatsoever.

If I move <h3><?php echo $term->name; ?></h3> so that it is outside of the loop (but within the foreach loop) it outputs the names of the terms fine.

So I imagine the problem must be something to do with the loop itself?



via Chebli Mohamed

Woocommerce - How to display price on shop page?

Using woocommerce storefront, how do I display the price of the product under the thumbnail and title on the shop page?



via Chebli Mohamed

Error when using setup_postdata()

I am trying to get the most recent and show it using the native function (e.g. get_the_title()), do NOT want to use $post['post_title'] but when I do this I'm an error.

global $post;

$featured_post = wp_get_recent_posts(array( 'numberposts'=>'1', 'post_type' => 'post' ));

foreach ($featured_post as $post) {

    setup_postdata($post);  

    echo get_the_title();

}

This is the error I get:

Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4601
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4603
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4605
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4606
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4617
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4625
Notice: Trying to get property of non-object in /.../wp-includes/query.php on line 4642



via Chebli Mohamed

Error in meta_query not get result

I have this WP_Query

<?php
        $args = array(
        'post_type' => 'banner',
        'posts_per_page' => 25 ,
        'meta_query' => array( 'relation' => 'AND',
        array('key' => 'ads_status','value' => '1'),
        array('key' => 'adsposition','value' => 'top'))
        );
        $slide = new WP_Query( $args );
    if ( $slide->have_posts() ) : while ( $slide->have_posts() ) : $slide->the_post();  
    $yourfile = get_post_meta(get_the_ID(), 'yourfile', true);  
    $adsposition = get_post_meta( get_the_ID(),'adsposition', true ); ?>
     <img src="<?php echo $yourfile; ?>" width="1350" height="515">
    <?php
endwhile; endif;
    wp_reset_query();
?>

I have tow meta box (ads_status,adsposition) and its saved good in wp-admin, but in home page not show any result, but when delete meta_query, Its work and get me result.

Where the error ??



via Chebli Mohamed

my wordpress site showing Out of memory error frequently

I have a WordPress site which is frequently showing out of memory error

i have also increased memory in config file

define('WP_MEMORY_LIMIT', '384M');

My php info file showing :

PHP Version 5.4.36 memory_limit 512M post_max_size 8M upload_max_filesize 4M

my error_log file showing below info

[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6029312) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 2533
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 7340032) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/category-template.php on line 519
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6291456) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1029
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 6553600) (tried to allocate 4480 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 3233
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 2097152) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/default-filters.php on line 108
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 9437184) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 248
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-load.php on line 56
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 262144) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-load.php on line 56
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 11272192) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/media.php on line 3020
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 11534336) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1396
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4456448) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/theme.php on line 591
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 14942208) (tried to allocate 1920 bytes) in xxxxxxxx/public_html/wp-content/plugins/wordpress-importer/wordpress-importer.php on line 420
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 4980736) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/user.php on line 1149
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 12320768) (tried to allocate 87 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1717
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Out of memory (allocated 15990784) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/postratings-stats.php on line 424
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 00:45:42 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:02 UTC] PHP Fatal error:  Out of memory (allocated 20447232) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_utility.php on line 352
[05-Oct-2015 02:05:02 UTC] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20100525/pdo_mysql.so: failed to map segment from shared object: Cannot allocate memory in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 18874368) (tried to allocate 3840 bytes) in xxxxxxxx/public_html/wp-content/themes/hdwallpapers/functions.php on line 221
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 15466496) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/wp-postratings.php on line 464
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 15990784) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-content/plugins/wp-postratings/postratings-stats.php on line 424
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Call to undefined function is_user_logged_in() in xxxxxxxx/public_html/wp-content/plugins/wp-fastest-cache/inc/cache.php on line 146
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 18612224) (tried to allocate 32 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 620
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 9600 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1526
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 78 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 14942208) (tried to allocate 1920 bytes) in xxxxxxxx/public_html/wp-content/plugins/wordpress-importer/wordpress-importer.php on line 420
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 10223616) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 2769
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/widgets.php on line 1391
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 13107200) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/ewww-image-optimizer/common.php on line 493
[05-Oct-2015 02:05:04 UTC] PHP Fatal error:  Out of memory (allocated 8650752) (tried to allocate 33280 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 733
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7602176) (tried to allocate 13440 bytes) in xxxxxxxx/public_html/wp-includes/comment.php on line 788
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1600
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 281
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 12582912) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/ewww-image-optimizer/ewww-image-optimizer.php on line 511
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 11010048) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/canonical.php on line 264
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 6815744) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 4961
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 1835008) (tried to allocate 690 bytes) in xxxxxxxx/public_html/wp-includes/wp-db.php on line 2146
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 12320768) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 1714
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 9175040) (tried to allocate 4480 bytes) in xxxxxxxx/public_html/wp-includes/deprecated.php on line 2223
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 9961472) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/taxonomy.php on line 822
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8388608) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/feed.php on line 529
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 02:09:36 UTC] PHP Fatal error:  Out of memory (allocated 6291456) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/post.php on line 993
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 2883584) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 183
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3145728) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 1158
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4718592) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/class-wp-theme.php on line 256
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 5767168) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 141
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4194304) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/query.php on line 2794
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3670016) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/capabilities.php on line 1235
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 3407872) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 3166
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 4980736) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/user.php on line 1300
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 2883584) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/formatting.php on line 183
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 10747904) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/update.php on line 141
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1579
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8650752) (tried to allocate 33280 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 733
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 11796480) (tried to allocate 8960 bytes) in xxxxxxxx/public_html/wp-includes/class-http.php on line 1518
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 9699328) (tried to allocate 79360 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 532
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 9437184) (tried to allocate 196608 bytes) in xxxxxxxx/public_html/wp-includes/script-loader.php on line 248
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8126464) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 2309
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7077888) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/post-template.php on line 1579
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 8912896) (tried to allocate 72 bytes) in xxxxxxxx/public_html/wp-includes/kses.php on line 1750
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 7864320) (tried to allocate 3072 bytes) in xxxxxxxx/public_html/wp-includes/comment-template.php on line 244
[05-Oct-2015 03:16:57 UTC] PHP Fatal error:  Out of memory (allocated 6029312) (tried to allocate 1280 bytes) in xxxxxxxx/public_html/wp-includes/link-template.php on line 2524
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 19660800) (tried to allocate 32 bytes) in xxxxxxxx/public_html/wp-includes/functions.php on line 1602
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 18087936) (tried to allocate 640 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_module_class.php on line 597
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 17825792) (tried to allocate 49152 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 2863
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Unknown: Cannot use output buffering in output buffering display handlers in Unknown on line 0
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 18612224) (tried to allocate 89 bytes) in xxxxxxxx/public_html/wp-content/plugins/all-in-one-seo-pack/aioseop_class.php on line 612
[05-Oct-2015 03:16:58 UTC] PHP Fatal error:  Out of memory (allocated 19922944) (tried to allocate 12288 bytes) in xxxxxxxx/public_html/wp-includes/template-loader.php on line 48



via Chebli Mohamed

Apply template to custom post type

Today I got a client that wanted custom template for each page and section within. I proposed Laravel custom sh3t, but he wanted WordPress, as it seems more easy to main( not from my experience ).

.. So far so good. I'm a little confused there.

So I decided that my parent entity would be page, so I can apply different template to each page. Then I have a section within this page, which should be not hardcored. User should have the ability to choose section layout ( template ), and remove or reorder sections within the current page. And Finally I have posts as they are the smallest entity in the website. Posts would be rendered as columns like in bootstrap ( col-md-2, col-lg-6 ), etc..

I decided to create a custom post type to use it as a section, but then I read that post types cannot have template, only pages can have ones. This compromised my plan so far and spend 5 hours in researching a solution( no exit ). So I need another strategy for doing this. I need templates for two entities.

Can someone suggest a solution to this problem? ( I will buy you a beer! )



via Chebli Mohamed

Add a custom SEND EMAIL to USERS in wordpress with ATTACHMENT

So i am tryinbg to allow my admins to go to USERS and view list of users. Within each user listed, i want a dropdown box to select which email template (Approximately 10) that essentially send a basic email out with attached word doc.

Once the box has been selected, then a once click button that SENDS that email out. Is this possible?



via Chebli Mohamed

post_type_link filter Post ID Twice

add_action('post_type_link','myfun');
function myfun($link,$post){
  if('MYPOSTTYPE' == get_post_type($post)){
     $link = $link.$post->ID.'/';
    }
  return $link;
}

Now when I access

http://ift.tt/1L2sNsI

It Redirects me to

http://ift.tt/1L2sL41

Why is this happening? If I disable this hook then the URL remains.

http://ift.tt/1VzyhFD



via Chebli Mohamed

Next and previous page buttons in wp-admin don't work

I have a problem I have never seen before. For some reason the next and previous page buttons in my wp-admin are messed up. Everything is working just fine on the website except for those buttons. The problem is, when I click the next page (for example, this would be page 2 of my list of posts), the url is "http://mywebsite/wp-admin/edit.php?paged=2".

The url doesn't have ".com" attached.

The database doesn't have the incorrect url anywhere, I've replaced 4.3.1 with a fresh copy, all other wp-admin links work, everything on the client facing side of the site works, literally everything else works just fine.



via Chebli Mohamed

Disable Garbage Collection?

I have a WP site which creates 500's errors for about 2% of Apache requests (mostly bots and crawlers). I'm not able to stack trace most of those requests with 500's neither to PHP or MySQL errors.

Is it good idea to disable a garbage collection (gc_disable()) for the whole WP site to prevent any memory leak caused by a theme or plugins?



via Chebli Mohamed

How To Only Display The Product Short Description On The Category Page

I need some expert advise on how to display the product short description on only the category pages. Right now the short description appears on the category page and the product details page. When using CSS to hide the short description, the short description is hidden on both pages. I'm hoping for someone who can help me with this problem.



via Chebli Mohamed

Youtube - Embed as IFRAME

When I embed a YouTube video through the suggest manner (paste url) it adds this as an object. Is there a way to embed as IFRAME intsead?



via Chebli Mohamed

Custom text in header on posts page

I need to add a custom blockquote-style blurb to the header on our home page, which is a posts page (using a child theme to Mantra).

Our site: http://www.lcnlit.org

Would like to add the blurb below the site title/tagline but above the tabbed navigation.

Thank you for answering this noob question.



via Chebli Mohamed

Any good web shop theme with option to add numbers of items in cart on homepage? [on hold]

I need some WP theme on themeforest or some else for a client that wants a webshop. So his demand is that listed items on homepage(featured items) must have option to add number of items without clicking on the listed item and entering it then adding the value of how much item he need.

Any link and reference is welcome. Thank you very much!



via Chebli Mohamed

Plugin - read post into blank page

I wonder if I could produce a blank page (not within theme) and write something to it - I need my custom page. I know about WP Ajax, but it's not that simple, cos I wanted to be able to get some data crossdomain (with PHP and regexp) but Im not sure with that.

Simply: I want bypass the theme (and its design) and give a blank page with custom plugin output. (Would be nice to be able to use WP functions)

Is it possible, or I have to use WP Ajax? Thank you


Edit1: I want to add something like post with it's permalink (following permalink structure), but without using theme - just blank page with data created by plugin

I know about including WP into external PHP files. I dont want any external file - it should be working within plugin



via Chebli Mohamed

Get gallery images from page ID

I have a page within WordPress called 'Gallery', the page ID is 128, and I need to display only the gallery images from that page on a different page with a different ID. The images were uploaded using the standard WordPress gallery functionality.

I've been trying to use get_children and a foreach loop to achieve it, but I can't seem to get only the gallery images from the page I need (ID 128).

Here's what I have so far:

$images = get_children( array( 
    'post_parent'    => 128, 
    'post_type'      => 'attachment', 
    'post_mime_type' => 'image', 
    'orderby'        => 'menu_order', 
    'order'          => 'ASC', 
    'numberposts'    => 999 
) ); 
if ( $images ) { 
    // looping through the images
    foreach ( $images as $attachment_id => $attachment ) {
        echo wp_get_attachment_image( $attachment_id, 'full' );
    }
}

How can I display gallery images from a WordPress page, on a different page?



via Chebli Mohamed

Change the size of the image preview on the media edit page

I'd like to increase the size of the preview image on the media edit page. At the moment it's too small to accurately crop.

../wp-admin/post.php?post=2758&action=edit&image-editor

image edit page



via Chebli Mohamed

WooCommerce Plugin: Hide Paypal section of Paypal Advanced Checkout and leave just Credit Card

Im running into an issue with this and hoping I can find some help. I am attaching a code snippet below with the applicable parts. This is for a Wordpress/WooCommerce setup and with the PayPal Advanced Plugin Im seeking to hide the first div container that is "pay with paypal" and leave my checkout with only the "pay with credit card" window. The only issue im running into is that these div containers/classes are all named exactly the same so Im running into walls with just hiding them without effecting them both. I also cant edit the names as this code is displayed via an iframe generated by PayPal. Any and all help is greatly appreciated!

<div id="iframeContainer">
    <!--Pay with PP starts -->
      <div class="shadowBox">
        <div class="shadowContent">
          <div class="miniController">
            <div class="headline">
              <span class="arrowicon"><strong>›</strong></span>


          </div>
        </div>
      </div>
    <!--Pay with PP ends -->

  <!--Pay with CC starts -->
 <div class="shadowBox">
    <div class="shadowContent">
      <div class="miniController">
        <div class="headline">
          <span class="arrowicon"><strong>›</strong></span>
          <span class="bartitle">
            <strong>



                  Pay with credit or debit card


            </strong>
          </span>
        </div>
      </div>
      <div class="miniContainer">
        <form method="post" id="formPayment" name="form_payment"     action="processTransaction.do" class="edit">
          <input type="hidden" name="subaction">
          <div id="fieldsCC">
            <div id="fieldrowCCNumber">
              <p class="group cc">
                <label for="cc_number"><span class="show">Card number</span></label>
                <span class="field">



                            <input type="text" id="cc_number" name="CARDNUM" autocomplete="off" value="">

                  ********

                    <input type="submit" id="btn_pay_cc" name="pay.x" value="Pay Now"   class="button primary" onclick="this.disable=true">





          </p>
        </form>
      </div>
    </div>
  </div>



via Chebli Mohamed

How to track clicks

On certain custom post type I would like track when visitor clicks to view for example phone number, website etc. I know I could do this with google analytics but I would also like to save this data to Wordpress, so I could show this info for post author on post edit screen. Also I would like to show total number of clicks and past week/month stats. Now how would you do this?

This is what I'm thinking. With jQuery detect click, then save the value to custom meta key with ajax. This would take care of the total clicks somewhat easily. But what about week/month clicks amount?

Does my idea have any point? Is there better ways to do it (maybe somehow with google analytics api?)?



via Chebli Mohamed

wp_insert_post not working anymore in new version?

On a site we're developing we allow registered users to submit content via Wordpress search if it doesn't already exist. If content is found it goes to the post.

If no content is found it submits the content via wp_insert_post. It then refreshes and finds the post.

After updating Wordpress and deactivating debug (we're almost ready to go live) the content submission isn't working.

$current_user = wp_get_current_user();  
$author_ID = $current_user->ID;
$title = get_search_query();

if( null == get_page_by_title( $title ) ) {

wp_insert_post(
        array(
            'comment_status'    =>  'default_comment_status',
            'ping_status'       =>  'default_ping_status',
            'post_author'       =>  $author_ID,
            'post_title'        =>  $title,
            'post_status'       =>  'publish',
            'post_type'     =>  'my',
            'comment_status'        =>      'open'
        )
    );

echo '<META HTTP-EQUIV="REFRESH" CONTENT="1">' ; 

Has something changed in the new versions?



via Chebli Mohamed

Display meta of custom gallery settings on frontend

I have created custom gallery setting fields by this code:

<script type="text/html" id="tmpl-slideshow-gallery-settings">
    <label class="setting">
      <span><?php _e('Display'); ?></span>
      <select data-setting="slideshow_attr">
        <option value="default"> Default gallery </option>
        <option value="zzlslideshow"> Slideshow </option>
        <option value="masonry"> Masonry gallery </option>
      </select>
    </label>
        <label class="setting">
        <span><?php _e('imgwidth'); ?></span>
        <input type="text" value="" data-setting="imgwidth_text" style="float:left;">
    </label>
        <label class="setting">
        <span><?php _e('imgheight'); ?></span>
        <input type="text" value="" data-setting="imgheight_text" style="float:left;">
    </label>
</script>
<script>

    jQuery(document).ready(function(){

      // add your shortcode attribute and its default value to the
      // gallery settings list; $.extend should work as well...
      _.extend(wp.media.gallery.defaults, {
        slideshow_attr: 'zzlslideshow'
      });

      // merge default gallery settings template with yours
      wp.media.view.Settings.Gallery = wp.media.view.Settings.Gallery.extend({
        template: function(view){
          return wp.media.template('gallery-settings')(view)
               + wp.media.template('slideshow-gallery-settings')(view);
        }
      });

    });

</script>

But now i could use al little help: How to get the values of my settingfields and display in frontend. By example when option slideshow is chosen i want to display flexslider2 on frontend. Can annyone tell me how to do so?



via Chebli Mohamed

Simple Share Buttons Add Plugin and Custom Post Type

First of all Simple Share Buttons Add is a great plugin to share WordPress contents to social media. Nonetheless, I encountered an issue with it. It is not possible to disable these button on custom post types while enabling it on posts. How to overcome that ?



via Chebli Mohamed

Permalinks keep reverting to 404 unless I re-save them

I'm running the latest (and constantly updated) version of WordPress on Nginx.

Every now and then I wake up to a site full of 404 errors. The fix is to go into the permalinks and just save the settings on that page. This typically fixes the issue for a day or so.

This was happening to another site of mine on the same server. It suddenly stopped being an issue. My point here is that not only do I not know what's causing it, but I can't even tell what's fixing it.



via Chebli Mohamed

Forbidden Access on WordPress login page

I have a WordPress website. Its login page is being forbidden due to some reason. Please guide me how can I access the login page? Thanks.



via Chebli Mohamed

Passing variable data from external jQuery file to options.php

I'm setting up a plugin that requires passing of a variable from a stand alone jQuery file to options.php. I have (I think) set up the scripts to be used in my plugin file like so:

function ndw_js_init(){
    wp_enqueue_script('jquery');
    wp_register_script( 'ndw_js', plugin_dir_url( __FILE__ ) . '/ndw_js.js', array( 'jquery' ), '', true );
    wp_enqueue_script( 'ndw_js', plugin_dir_url( __FILE__ ) . '/ndw_js.js', array(), '1.0.0', true);
    $scriptdata = array('admin_ajax' => admin_url( 'admin-ajax.php' ));
    wp_localize_script( 'ndw_js', 'toremove', $scriptdata);
}
add_action('admin_init', 'ndw_js_init');

Where I am coming unstuck is in the jQuery file. The variable is passed onclick. So far I have this which works fine (tested using an alert()):

$('tr td .widget-remove a').click(function(){
     var toremove = $(this).attr('rel');
     var url = 'options.php';
     // Out of ideas
});

So what I need is help to use the correct AJAX syntax to pass the value of var 'toremove' to 'options.php' and then do something in 'options.php' using the value of 'toremove'.

Hope that makes sense!



via Chebli Mohamed

Shortcode not showing anything

I am using this code, but nothing is being shown on the front page. It seems the shortcode is registered correctly though.

function choose_ashtopbar() {
?><img src="/images/flag_globe2.png" class="ttupmg" /><div class="dmzeus"><ul><li class="f-selection">London<ul><li>New York</li><li>Paris</li><li>Milan</li></ul></li></ul></div><?php
}

function register_ashcodes(){
add_shortcode('ashtopbar', 'choose_ashtopbar');
}

add_action( 'init', 'register_ashcodes');



via Chebli Mohamed

using href when creating wordpress plugin calls empty page instead of php file

I'm currently developing my first wordpress plugin. It's a plugin which manages all the members and other data from a club. I read the members from a MySql database which works fine. What I now want is to set a link to each member name, which will call the details of the member when the user clicked.

I have three php files for now:

1st: menu.php: This just creates a menu item in the backend

2nd: admin.php: This contains the MySql connection and the loop to get all the members. This also contains the link for each member.

3rd: member.php: This file should be the details page to each member (depending on what member the user selected).

while ($row = mysql_fetch_array($result, MYSQL_NUM))
{
    $path = "member.php?memberid=" . $row[0];
    $url = admin_url($path);
    echo "<tr><td>" . $row[0] . "</td><td><a href='{$url}'>" . $row[1] . "</a></td></tr>";
}

As you can see I'm trying to call member.php from admin.php and pass the member's ID using the URL.

My problem now is that when I click on a link, it just call an empty (white) page, without any wordpress design. For testing, I just echoed some random text, but this is not displayed, neither.

What am I doing wrong? Is this even possible in this way? Or how can I achieve this?

I don't know if it helps you helping me, but here you can see the code from menu.php:

add_action('admin_menu', 'AddMenuItem');

function AddMenuItem()
{
    add_menu_page('Admin Plugin', 'Admin Plugin', 'add_users', 'admin-plugin\admin.php', '',  '', 100);
}



via Chebli Mohamed