lundi 20 avril 2015

How to add a meta box for categories in Wordpress?

I want to add two meta boxes for categories, so that I can add additional content or information to each of my categories.

In the template of the categories I will then read the contents of those meta boxes, but how can I add meta boxes to categories? I can only see documentation for doing this on pages and posts or custom post types, but categories?

Error in plugin for WooCommerce

I have recently started writing a plugin for the woocommerce, and everything worked flawlessly before I tried to hook the extension to the system.

I have a following code inside my class.

function add_gateway($methods)
{
  $methods[]  = 'Rentalbloom_WSPay';
  return $methods;
}
add_filter('woocommerce_payment_gateways', 'add_gateway');

Class has constructor defined as a public function __contruct() so it shouldn't have problems with the access, but when I try to run this I get the following error.

Parse error: syntax error, unexpected T_STRING, expecting T_FUNCTION and the error points to the add_filter line written above.

I don't know if this is relevant, but I'm using a PHP version 5.3 on the APMPPS stack on the OS X.

How to add location url in Wordpress(Appearance --> Menu --> URL)?

I'm working on WP site which is currently having this kind of testing instace url: http://someipaddress/~directory/directory/ and then "wp-admin"

now If I want to link of any page in top navigation through wp-admin--> Appearance --> Menu

I need to use "/~directory/directory/" in URL field(THIS IS WHAT THE PROBLEM IS)

/~directory/directory/
Now I've to move it on production instance, and it has different kind of url like : "http://mywpsite.com/", so again I need to change this URL over there.

Does anyone has any idea how to tackle this?

Adding post with thumbnail image to Wordpress blog with JoeBlogs / C#

I'm trying to add new post with thumb image but i still couldnt get success on it.

 public static int addContent(int postType, string title, string body, string post_thumbnail, string[] categories, string[] tags, DateTime dateCreated)
{
  Post post = setPost(postType, title, body, post_thumbnail, categories, tags, dateCreated);
  using (var wrapper = getWordPressWrapper())
  {
    return wrapper.NewPost(post, true);
  }
}

get setPost method,

public static Post setPost(int postType, string title, string body, string post_thumbnail, string[] categories, string[] tags, DateTime dateCreated)
{
  string type = postType == 1 ? "post" : "page";
  var customFields = new CustomField[] { 
    new CustomField() { 
        // Don't pass in ID. It's auto assigned for new custom fields.
        // ID = "name", 
        Key = "post_thumbnail", 
        Value = post_thumbnail
    } 
    //,
    //     new CustomField() { 
    //    // Don't pass in ID. It's auto assigned for new custom fields.
    //    // ID = "name", 
    //    Key = "post-thumbnail", 
    //    Value = post_thumbnail
    //}  ,
    //     new CustomField() { 
    //    // Don't pass in ID. It's auto assigned for new custom fields.
    //    // ID = "name", 
    //    Key = "post-thumbnails", 
    //    Value = post_thumbnail
    //} ,
    //     new CustomField() { 
    //    // Don't pass in ID. It's auto assigned for new custom fields.
    //    // ID = "name", 
    //    Key = "thumbnail", 
    //    Value = post_thumbnail
    //} 
  };
  return new Post
  {
    PostType = type,
    Title = title,
    Body = body,
    Categories = categories,
    Tags = tags,
    DateCreated = dateCreated,
    CustomFields = customFields
  };
}

as you see its commented. I tried everything to post thumb images.

I've tried post_thumbnail, post-thumbnail, post-thumbnails, thumbnail keys but nothing happen.

How can i do that?

Get Woocommerce customer order language

I'm developing a complementary plugin for woocommerce. I have a sql request that gets all the order and customer info, but i need to get the language from the order.

How can i detect the language was using a customer when he made an order? Is it registered somewhere?

In other CMS like prestashop it's stored as id_lang in orders and customer tables.

Sorry for my English.

Thanks in advance!

WP: wp_list_pages different sort_column for depths

I'm using wp_list_pages to generate a custom menu for certain pages and it works as expected.

I was wondering if it's possible to use 'sort_column' parameter based on depth, so that first-level pages (top parent pages) are sorted by let's say 'menu_order' and other level pages are sorted using 'post_title'.

By reading codex I didn't find what I was looking at. Will I need to use walker to achieve this? If so, I would be glad if I could get some tips on this.

Thanks

Wordpress Frontend Ajax with wp_localize_script Error: ajaxurl is not defined

I'm trying to create markers on a map via ajax on a wp theme. After some struggle I found out that I can't use any php file to get data via ajax, I have to use the admin-ajax.php file.

Accordingly to many examples, this is my code

in functions.php

add_action( 'wp_enqueue_scripts', 'add_frontend_ajax_javascript_file' );
function add_frontend_ajax_javascript_file()
{
   wp_localize_script( 'frontend_ajax', 'frontendajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
    wp_enqueue_script( 'ajax_custom_script',  get_stylesheet_directory_uri() . '/includes/ajax-javascript.js', array('jquery') );

}

add_action( 'wp_ajax_get_post_information', 'get_post_information' );
add_action( 'wp_ajax_nopriv_get_post_information', 'get_post_information' );


function get_post_information() 
{ 

$get_this= $_GET['this'];
$get_that= $_GET['that'];

...my select...

echo json formatted data
}

The js file is loaded and working, it does other stuff before the ajax call, where it stops for an error in this line:

$.post({ 
        url:frontendajax.ajaxurl,
        {
            action: 'get_post_information',
            data: data
        },
        success: function(response) {

But I always Have the same error:

Reference Error: frontendajax.ajaxurl is not defined

where is my error?

PS: I use get_stylesheet_directory_uri() because I am in a child theme.

Wordpress not installing index.html

I am trying to install a theme, but all the files in the theme are of .html extension. Due to which wordpress is not accepting index.html, I changed it to index.php, it was installed successfully this time, but the style was not applied. Can anyone help me how to solve this issue.

Wordpress Open Social Error:"Strict Standards: Only variables should be passed by reference"

I am using the Open Social Plugin in Wordpress. I also installed the Debug Plugin to see what is going on. I get a PHP Error saying:

Strict Standards: Only variables should be passed by reference in /wp-content/plugins/open-social/open-social.php on line 111.

Line 111 in open-social.php:

'google'=>"http://ift.tt/1IwJpbJ".(isset($_SESSION['WPLANG_LOCALE'])?$_SESSION['WPLANG_LOCALE']:'en_US')."&sl=zh-CN&tl=".(isset($_SESSION['WPLANG_LOCALE'])?reset(str_split($_SESSION['WPLANG_LOCALE'],2)):'en')."&u=%URL%"

Does anyone know what is wrong with this line? I am stuck here.

How get posts from a subcategory of a category by name?

I'm trying to create a subcategory template of a defined category. For example, for each one, I would like to check if his subcategory Photos exists and to get posts of this.

Here is my category tree:

— Category Sessions
— — Subcategory Session 2015
— — — Subcategory Photos
— — — Subcategory ...
— — — Subcategory Videos
— — Subcategory Session 2014
— — — Subcategory Scores
— — Subcategory Session 2013
— — — Subcategory Photos
— — — Subcategory ...
— — — Subcategory Videos

If subcategory Photos of this session category exists :

My idea is to have a query such as :

$wp_query = new WP_query(... Session 20XX/Photos ...&showposts=20);

Is there a way to do that please?

Insert query not working for non-logged in user in wordpress

I am trying to create a function for count post views. for this i have added code in my function file.

Here is my code:

function processpost_views( ){
        global $user_ID, $post;
        if( is_int( $post ) ) {
            $post = get_post( $post );
        }
    if( !wp_is_post_revision( $post ) )
    {
        if( is_single() || is_page() )
        {
            $id = intval( $post->ID );
            global $post;

            $date = explode('-', date('W-d-m-Y', current_time('timestamp')));
                foreach (array(
                0 => $date[3].$date[2].$date[1],    // day like 20140324
                1 => $date[3].$date[0],             // week like 201439
                2 => $date[3].$date[2],             // month like 201405
                3 => $date[3],                      // year like 2014
                4 => 'total'                        // total views
                ) as $type => $period)
                {
                insertView($post->ID, $type, $period, 1);
                }
        }
    }

}

second function

function insertView( $id, $type, $period, $count = 1 ) {

    global $wpdb;
        $wpdb->postviews = "{$wpdb->prefix}postviews";
        $wpdb->test = "{$wpdb->prefix}test";
        $count = (int) $count;      

        if ( ! $count ) {
            $count = 1;
        }
        $sql = $wpdb->prepare("
                INSERT INTO " . $wpdb->prefix . "postviews (id, type, period, count)
                VALUES (%d, %d, %s, %d)
                ON DUPLICATE KEY UPDATE count = count + %d",
                $id,
                $type,
                $period,
                $count,
                $count
            );      

        $wpdb->query($sql);


}

add_action( 'wp_head', 'processpost_views' );

In this above code, my insert and update queries work i am logged in but when i am guest/ logged user this code not work. Please help me.

my message in admin bar in wordpress

Creating my wp 4.2 plugin I make check if dependable plugins are installed. The question is I would like to show error in admin bar, but did not find how to make it. Can be better decision ?

Thanks!

How can I make this code work in css?

I have this page

http://ift.tt/1Hnia4O

right column passed as you can see below.

This is because this code

.theme-page-wrapper.right-layout .theme-content, 
.theme-page-wrapper.left-layout .theme-content {
    width: 90% !important; //This should be the 73%
}

I only want 70% value on this page and I tried this code

body.page.page-id-7674.theme-page-wrapper.right-layout .theme-content, 
.theme-page-wrapper.left-layout .theme-content {
    width: 73% !important;
}

Unfortunately this code is not working and can not understand why. Can you please help me solve this problem?

Thanks in advance!

WordPress - If Category selected = ?, display?

Currently, I am displaying all of my posts in a list, which works fine, as below:

    <div class="container">
  <div class="row" style="margin-top:20px;">
    <?php 
    $args = new WP_Query();
    $loop = new WP_Query( $args );
    while ($loop->have_posts() ) : $loop->the_post();
    ?>
    <div class="col-md-8 col-sm-12 col-xs-12">
      <div class="postsize">
      <div style="float: left; padding-right:20px;">
        <?php echo get_the_post_thumbnail( $page->ID, 'categoryimage', array('class' => 'faqposts')); ?>
      </div>
      <h5 class="captext"><?php the_title(); ?></h5>
      <span class="entry-date-orange"><?php echo get_the_date(); ?></span>
      <p style="margin-top:10px";><?php the_excerpt(); ?></p>
    </div>
  </div>
  <?php endwhile; ?>
  <?php wp_reset_query(); ?> 


</div>
</div>

What I need, is options on the right hand side, which shows all my post categories. Once a post category is selected, the list of posts is recalculated and displays only the posts from the selected categories.

So for example, I would have the below layout:

POST CATEGORY LIST

POST

POST

POST

POST

POST

And once a selected post category is selected, the list on the right changes.

Any ideas? Thank you.

Redirection loop on activating https on cloudflare enabled wordpress site

I've a Wordpress site (with latest version). The site was running properly until I've activated force https from cloudflare! Cloudflare now a days provides free ssl and google also likes SSL enabled sites. That's why I've activated SSL from cloudflare and added page rule in cloudflare to force https.

I've also changed site's base url and home page url with https, but it still having redirection loop.

I don't have any idea if I'm supposed to post my personal site's URLs here or not. If required I will post the URL.

Can anyone help please.

Failure to login in Car park Booking plugin in wordpress [on hold]

I purchase WordPress plugin name "car park booking" its working fine but after 1 year it stop working.Now its admin panel can not login if i give wrong email and password then show error but if i give correct email and password then it redirect same page.

I am using woocommerce-composite-products (plugin). i want to Apply component-level discounts over sale prices?

In woocommerce-composite-products (plugin) i want apply discount based on sales price. by default it calculate by regular price.

as per woo documentation I can use filter woocommerce_composited_product_discount_from_regular. my code is below

add_filter( 'woocommerce_composited_product_discount_from_regular', 'wc_cp_composited_product_discount_from_regular', 10, 3 );


function wc_cp_composited_product_discount_from_regular( $from_regular, $component_id, $composite_id ) {
return false;
}

I tired to add this code in plugin and add in wp theme but it working.

can anyone help me ?

W3 total cache cdn url not working with theme

I am currently trying to integrate W3 Total Cache to a wordpress website and i have noticed some rather weird behavior with the CDN url request being sent.

I am currently using s3/cloudfront and i have my CNAME (cdn.example.com) pointing to the cloudfront url.

Now all the images, css and javascript that are not part of the theme are rendering properly with the CDN CNAME url.

example: http://ift.tt/1JlNEXI
http://ift.tt/1yJU42H
http://ift.tt/1JlNEXL

(May I also add that this also happens with the cloudfront url as well.) But when it come to the css and javascript that are part of the woo theme it renders as follows.

http://ift.tt/1yJU42I
http://ift.tt/1JlNEXM

I have taken this up with the theme developers and others concerned but very little has come out from them.

I have looked at various options like using preg_replace to match the occurrence of the weird url and replace it with an empty string.

This however did not work because i was probably using/calling the wrong add_action or add_filter from the reference documentation http://ift.tt/1yJU42L and that of wordpress (I mean wp_head or wp_footer).

As you may have figured out I am not experienced with wordpress and I ask that you please help explain what is going on or wrong with this and possible ways i can resolve this matter.

Thanks for your help.

How to use jquery in WordPress page

How could I make this code to work in a WordPress page?

<!DOCTYPE html>
<html>
<head>
<script src="http://ift.tt/1xDNnh9"></script>

<script>

jQuery(document).ready(function($) {
    $("a").click(function(){

        $('#versie').text('Welkom '+ $(this).attr('data-name'));
    });
});
</script>

</head>

<body>

<div id="div1"><h2>Selecteer de gewenste versie: <span id="versie"></span></h2></div>

<a href="#" data-name="2007">2007</a> | <a data-name="2010" href="#">2010</a> | <a data-name="2013" href="#">2013</a>  

</body>
</html>

i translate my site into arabic so i need to change (ALL) to arabic word [on hold]

i need to change the word ALL to another word how? when u make many pages at the main page or any link you will get 1 2 3 4 pages and all to show the all pics or show the full info at the page so if i need to change the word of ALl to another word how to do it?

How can I detect if user has subscribed Memberpress product already

How can I detect if user has already bought a memberpress product.

I'm searching something like this:

if(have_subscription){ 
   //code to add button
}else{
   // code to add something else
}

Thanks in advance!

Wordpress - Permalink of sub-category in loop

I've got a template looping through each of the sub-categories in the main category you've selected. The title of each I would like hyperlinked, so if you select a sub-category you can now go to that specific categories posts.

However when using <?php get_category_link( $category_id ); ?>, it outputs the permalink of the parent category instead.

<div class="row">
<?php $i = 1; $categories = get_categories("child_of=$cat"); foreach ($categories as $cat) { ?>
    <div class="col-md-6">
        <?php query_posts("cat=$cat->cat_ID&posts_per_page=1&order=ASC&orderby=name"); ?>
        <div class="top-category-container">
            <div class="category-label">
                <span>Latest From</span>
                <h2><a href="#"><?php single_cat_title(); ?></a></h2>
            </div>
            <?php while (have_posts()) : the_post(); ?>
                <div class="post">
                    <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
                    <div class="article-img">
                        <a href="<?php the_permalink(); ?>"><?php echo the_post_thumbnail('', array('class' => 'img-responsive')); ?></a>
                    </div>
                    <p><?php the_excerpt(); ?></p>
                </div>
            <?php endwhile; ?>
        </div>
    </div>
<?php } ?> 
</div>

LIVE URL: http://ift.tt/1HKPUtl

can i redirect 404 pages to related pages manually?

I have 450+ pages with 404Error, I want to redirect them on their relevant pages without any plugin, is there any way to add some code and automatically redirect all pages to their relevant pages>

woocommerce product slider plugin work for category name or id ???

add one ring product category in woocommerce.then I have set these category all fetaured image in home page with slider.which plugin work for product category name or id???

Wordpress multilangual urls

I am trying to create a multilangual website with worpdress. So far I have created a website that has different content depending on the language in the url. But I am also trying to have the urls translated in the selected language.

So for example if I make a page in wordpress, and translate it into 3 different lanagues it should generate 3 different page names for that single page.

For example the page is called hello world and the language is english the urls should like this:

http://ift.tt/1CYqItQ

But if the language is netherlands the url should like this:

http://ift.tt/1EdM6RG

And both urls are the same page in wordpress, only the url should be translated.

Currently I am using qTranslate-X for the translate of the website.

Does anyone know how I can do this ?

"Un-require" a function

My WP theme's parent functions.php has

require get_template_directory() . '/inc/template-tags.php';

inside that file is a function I want to change. The problem is there's a bunch of other functions in there that I don't want to touch. I could just copy the whole file into child theme and unregister/unequene that file. I was wondering if there is an easier way.

inside template-tags.php the function I want to change values in is called

function web2feel_content_nav( $nav_id ) {

... content i want to change in here

endif; // web2feel_content_nav

It is called in my single.php file using

<?php web2feel_content_nav( 'nav-below' ); ?>

It was easy to just change the parent file, but I don't want to touch the parent, so I just want to override that one function and change it to the new/fixed one.

Woocommerce custom box

is there a plugin for woocommerce with this functionality:

I have single products with variations, now i want to sell them in boxes, the user can choose different products and quantities. I want to limit overall product quantity into the box.

This is an example for a 10-item customized box:

ITEM A : 5 quantity
ITEM B : 3 quantity
ITEM C : 2 quantity

if the customer add another products, woocommerce popup an error (max quantity reached).

I tried "woocommerce product bundles" and "woocommerce composite products" with no luck, they don't have such functionality.

I have this error in woocommerce "Gateway Disabled: PayPal does not support your store currency"

I have this error in my woocommerce web site:

Gateway Disabled: PayPal does not support your store currency.

Any one have specific solution for this?

I am using currency Saudi Riyaal(SAR) and american Dollars($).

Include custom post type in Wordpress loop

Sorry, I think I read every post about this but cant get it to work.

I have a Wordpress custom post typ called "external" and I would like to show both the post from "external" aswell as my normal standard posts at the same time on my homepage.

This is my loop:

<?php 
get_header(); 

if ( get_query_var('paged') ) { $paged = get_query_var('paged'); }
elseif ( get_query_var('page') ) { $paged = get_query_var('page'); }
else { $paged = 1; }?>


<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(''); ?>>
    <?php the_content(); ?>
</div>
<?php endwhile; wp_reset_postdata(); endif; ?>    

How can I include the "external" posts in this code?

The theme then uses blocks to display content on the startpage, here is block8.php with a post query.

function block_eight_ajax_query($atts='') {
    $args = array (
$is_ajax = 0;
if($atts==''){
    $is_ajax=1;
    $atts=$_GET;
    if($atts['global_query']){
        unset($atts['no_found_rows']);
        unset($atts['suppress_filters']);
        unset($atts['cache_results']);
        unset($atts['update_post_term_cache']);
        unset($atts['update_post_meta_cache']);
        unset($atts['nopaging']);
    }
}
$atts['is_ajax'] = $is_ajax;
$query = null;
$query = new WP_Query( $atts );
$html = '';
if ( $query->have_posts() ) {
    ob_start();
    $i = 1;
    while ( $query->have_posts() ):
        $query->the_post();

        $atts['video'] = rd_field( 'abomb_post_video' );
        $atts['extern'] = rd_field( 'extern' );
        $atts['audio'] = rd_field( 'abomb_post_audio' );
        $atts['gallery'] = rd_field( 'abomb_post_gallery' );
        $atts['counter'] = $i;
        block_grid_content($atts);
        if ($atts['column'] == 'grid-12') { $divide = 1; }
        else if ($atts['column'] == 'grid-3') { $divide = 4; }
        else if ($atts['column'] == 'grid-4') { $divide = 3; }
        else { $divide = 2; }
        if ($i%$divide==0 && $divide!=1) {
            echo '<div class="clear"></div>';
        }
        $i++;
    endwhile;
    if ($atts['nav'] == 'numbered') {
        echo '<div class="grid-12">';
            rd_pagination($query->max_num_pages);
        echo '</div>';
    }
    wp_reset_postdata();
    $html = ob_get_clean();
    if($is_ajax==1){
        echo $html;
        exit();
    }
    return $html;
}
else{
    if($is_ajax==1){
        echo '-11';
        exit();
    }
    return '';
}
}

Update: I added this code to functions:

add_action( 'pre_get_posts', 'add_my_post_types_to_query' );


function add_my_post_types_to_query( $query ) {
if ( $query->is_home() && $query->is_main_query() )
    $query->set( 'post_type', array( 'post', 'extern' ) );
return $query;
}

Now I can see the posts in for exampel the search result but I need the Query in Block8.php to fetch them aswell.

I Thanks!

How can I add adrag & drop option to customizer?


I want to give the admin the possibility to choose layouts & categories in the order they want (cat 4 using layout B, cat 2 with layout D....), so How can it be done with customizer with drag & drop ?
I don't use an admin panel, just the customizer
thank you

Sql query to set wordpress category

Hi I use an sql query to set all my post type to specify category and I use:

for($i = 0;$i<$count;$i++)
{
    if($i<22)
    {
    $order = "UPDATE wp_term_relationships 
                                  SET term_taxonomy_id='18' 
                                  WHERE object_id='$id[$i]'";

    $retval = mysql_query( $order, $conn );
    if(! $retval )
    {
      die('Could not update data: ' . mysql_error());
    }
    else
        echo 18;
    }
    else{
        if($i<178){
            $order = "UPDATE wp_term_relationships 
                                      SET term_taxonomy_id='15' 
                                      WHERE object_id='$id[$i]'";

        $retval = mysql_query( $order, $conn );
        if(! $retval )
        {
          die('Could not update data: ' . mysql_error());
        }
        else
            echo 15;
        }


        else{
            $order = "UPDATE wp_term_relationships 
                                              SET term_taxonomy_id='29' 
                                              WHERE object_id='$id[$i]'";

                $retval = mysql_query( $order, $conn );
                if(! $retval )
                {
                  die('Could not update data: ' . mysql_error());
                }
                else
                    echo 29;
                }

        }

NOTE I'm not seeing any error

.htaccess - ReWriteCond

My WordPress installation has generated a nice .htaccess file which prevents my images from being hotlinked. This is really nice, but I need to fetch images from a new bunch of php sites which are running outside my wordpress installation (on the same server)

Now I tried to update my .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?austrianweddingaward.at    [NC]  
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteRule ^_security /wp-content/plugins/password-protect-   wordpress/certificate.txt [QSA,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

But even when I try to show an image using this line of code: <img src="<?php echo $row->url; ?>" alt="" /> only the nice "?" instead of the image will be shown. (the source of the image is correct:

Image

Wordpress plugin interacting with custom table

This is my first foray into the world of Wordpress plugins.

I have managed to create the plugin, activate it and display records from a custom table.

Now I want to be able to add/edit/delete records from href tags using AJAX

This is my code thus far, however, it is not deleting the selected record.

<?php
    global $wpdb;
    $items = $wpdb->get_results("SELECT * FROM wp_freight;");
    echo "<h1>Plate Costs</h1>";
    echo "<table class='wp-list-table widefat fixed users'>";
    echo "<tr><thead><th>ID</th><th>Origin</th><th>Destination</th>   <th>Price</th><th></th></tr><thead>";
    foreach($items as $item){
       echo "<tbody><tr>";
       echo "<td>".$item->id."</td>";
       echo "<td>".$item->origin."</td>";
       echo "<td>".$item->destination."</td>";
       echo "<td>".$item->price."</td>";
       echo "<td><a class='button button-primary' href='' style='margin-   right:10px'>Edit</a><a class='button button-primary' href='#'   onclick='ajaxDeleteItem(".$item->id.")'>Delete</a></td>";
       echo "</tr></tbody>";
     }
     echo "</table>";   


    function delete_row() {
        $id = $_POST['element_id'];
        $table = 'wp_freight';
        $wpdb->delete( $table, array( 'id' => $id ) );
        echo $id;
    }

    add_action('wp_ajax_your_delete_action', 'delete_row');
    add_action( 'wp_ajax_nopriv_your_delete_action', 'delete_row'); 

?>

<script>
    function ajaxDeleteItem(a){
    var dataString = 'userID='+ a;
    jQuery.ajax({
        type: "POST",
        url: ajaxurl,
        data: {"action": "your_delete_action", "element_id": a},
        success: function(msg){
            alert( "Item " + a + " deleted." );
        },
        error: function(){
            alert('failure');
          }
    });
    }
</script>

dimanche 19 avril 2015

jQuery cookie not working properly in wordpress

I make my own accordion menu with html + jquery its working perfectly to forth level, then i add a cookie code from net and do some extra work it also work 100% perfectly in html.


My complete HTML + jQuery code reference is in JS-Fiddle Accordion Menu with Cookie


Now i merge it in my wordpress menu very carefully, it shows very weird behavior. when i click on plus the sub menus are open and i click on sub category the page goes to that category but the menu is close but when i again open the sub menu and click on the menu or refresh the page its work. I worried why in wordpress the jquery cookie not working.


Here is jquery cookie + jquery accordion code:



jQuery(document).ready(function () {


// baking cookie ;p
function set_cookie(ID) {
document.cookie = ID + "=opened";
}

// getting it out from the oven... ;)
function get_cookies_array() {

var cookies = {};

if (document.cookie && document.cookie != '') {
var split = document.cookie.split(';');
for (var i = 0; i < split.length; i++) {
var name_value = split[i].split("=");
name_value[0] = name_value[0].replace(/^ /, '');
cookies[decodeURIComponent(name_value[0])] = decodeURIComponent(name_value[1]);
}
}

return cookies;

}

// yuck... sorry i don't know how to cook :S
function unset_cookie(cookie_name) {
var cookie_date = new Date();
cookie_date.setTime(cookie_date.getTime() - 1);
document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

var tree_id = 0;
jQuery('ul.b29-tree li:has(ul)').addClass('has-child').prepend('<span class="switch">+</span>').each(function () {
tree_id++;
jQuery(this).attr('id', 'tree' + tree_id);
});
// Accordion code
jQuery('ul.b29-tree li > span.switch').click(function () {
var tree_id = jQuery(this).parent().attr('id');
if (jQuery(this).hasClass('open')) {
jQuery(this).parent().find('ul:first').slideUp('fast');
jQuery(this).removeClass('open');
jQuery(this).text('+');
unset_cookie(tree_id)
} else {
jQuery(this).parent().find('ul:first').slideDown('fast');
jQuery(this).text('-');
jQuery(this).addClass('open');
set_cookie(tree_id)

}
});

var cookies = get_cookies_array();
for (var name in cookies) {
$('#' + name).find('> ul').css({'display' : 'block'});
$('#' + name).find('> span').addClass('open').text('-');
}

});


I am working in wordpress on my xamp so i can't give you that link but above link is the demo of html


Thumbnail Grid shows up in reverse order

I have a wordpress site that uses a thumbnail grid (9 posts, 3 posts wide, responsive ) the featured image on each post creates the grid.


My code that controls the grid is



<?php
/**
* controls main grid images
*/
?>

<article id="post-<?php the_ID(); ?>" <?php post_class('col-md-4 col-sm-4 pbox '); ?>>

<div class = "box-ovrly">
<h2 class="box-title"><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<div class="box-meta"><?php the_category(', '); ?></div>
</div>

<?php
$thumb = get_post_thumbnail_id();
$img_url = wp_get_attachment_url( $thumb,'full' ); //get full URL to image (use "large" or "medium" if the images too big)
$image = aq_resize( $img_url, 750, 560, true ); //resize & crop the image
?>

<?php if($image) : ?>
<a href="<?php the_permalink(); ?>"> <img class="img-responsive" src="<?php echo $image ?>"/></a>
<?php endif; ?>

</article><!-- #post-## -->


It creates a grid but it shows up in the reverse order (9 to 1, instead of 1 to 9) This wouldn't be a huge deal but I have 'next' and 'previous' buttons which don't co-ordinate to the post.


Ex. on my first post the 'previous' button shows up cause it thinks its on the 9th post, etc.


the back/next menu is created with the following



function web2feel_content_nav( $nav_id ) {
global $wp_query, $post;

// Don't print empty markup on single pages if there's nowhere to navigate.
if ( is_single() ) {
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );

if ( ! $next && ! $previous )
return;
}

// Don't print empty markup in archives if there's only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) )
return;

$nav_class = ( is_single() ) ? 'post-navigation' : 'paging-navigation';

?>
<nav role="navigation" id="<?php echo esc_attr( $nav_id ); ?>" class="<?php echo $nav_class; ?> row">
<h1 class="screen-reader-text"><?php _e( 'Post navigation', 'web2feel' ); ?></h1>

<?php if ( is_single() ) : // navigation links for single posts ?>

<?php previous_post_link( '<div class="nav-previous col-xs-6">%link</div>', '<span class="meta-nav">' . _x( '&larr;', 'Previous post link', 'web2feel' ) . '</span> %title' ); ?>
<?php next_post_link( '<div class="nav-next col-xs-6">%link</div>', '%title <span class="meta-nav">' . _x( '&rarr;', 'Next post link', 'web2feel' ) . '</span>' ); ?>

<?php elseif ( $wp_query->max_num_pages > 1 && ( is_home() || is_archive() || is_search() ) ) : // navigation links for home, archive, and search pages ?>

<?php if ( get_next_posts_link() ) : ?>
<div class="nav-previous col-md-6"><?php next_posts_link( __( '<span class="meta-nav">&larr;</span> Older posts', 'web2feel' ) ); ?></div>
<?php endif; ?>

<?php if ( get_previous_posts_link() ) : ?>
<div class="nav-next col-md-6"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">&rarr;</span>', 'web2feel' ) ); ?></div>
<?php endif; ?>

<?php endif; ?>

</nav><!-- #<?php echo esc_html( $nav_id ); ?> -->
<?php
}

Wordpress Calendar only to show months without days

We have a WordPress website and we need to have event calendar in footer as widget (all that is fine). The issue is we need to show only months from (1-12) without any dates and days as u can see it in (http://ift.tt/1EizkS2) in footer, its not working only HTML and style applied


Form submit fails on second time submit

Hello I am working on wordpress and below is my php code. I show images by fetching their path from database and have a vote button with every image and when it is clicked the vote is added to the votes table. After vote is added I want to show that queue of images again with updated votes for all the images. I am doing this successfully but when I press vote button for the second time to add second vote I get a message that database insertion failed. Below is my code and snapshot of how my page looks and what is the error are all mentioned below. Images are comming from articles table which has 1:N relationship with votes table.


PHP Code



if(isset($_POST['submit'])){
$ccc = $_POST['comp'];
$cat =$_POST['category'];
global $wpdb;

$compp = $wpdb->get_var("SELECT competition FROM competition ORDER BY cid DESC LIMIT 1");
$userid = $_POST['id'];
$myvote = 1;

if($wpdb->insert(
'zvotes',
array(
'zvotes' => $myvote,
'zcompetition' => $compp,
'aid' => $userid
)
) == false) wp_die('Database Insertion failed'); else echo 'your vote was successfully recorded';
//show the updated results


//get current competition value



$sqll = "SELECT articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title, Sum(zvotes.zvotes) AS votessum FROM articles LEFT JOIN zvotes on articles.aid=zvotes.aid WHERE articles.category = '$cat' && articles.competition = '$ccc' GROUP BY articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title ORDER BY votessum";

$results = $wpdb->get_results($wpdb->prepare($sqll)) or die(mysql_error());

foreach( $results as $result ) {
echo '<form action="" method="post">';
echo "<input name='category' type='hidden' value='$result->category'>";
echo $result->title.'<br>';
echo "<img src='$result->path' width='150' height='150' >" . '<br><br>';
echo $result->body.'<br>';
echo "<input name='comp' type='hidden' value='$result->competition'>";
echo $result->username.'<br>';

echo $result->votessum.'<br>';
echo "<input style='margin-bottom:30px;' value='vote' name='submit' type='submit'/></form>";

}//end of foreach



}
/////////////////////////////////////////////////////////////////////////
// drop down
echo '<form action="" method="post">';
echo '<select name="category" id="category" style="width:250px; background-color:lightgrey;">';
echo '<option value="" disabled="disabled" selected="selected" ">Select category</option>';
echo '<option value="My Testimony">My Testimony</option>';
echo '<option value="Love & Relationships">Love & Relationships</option>';
echo '<option value="Miscellaneous">Miscellaneous</option>';
echo '</select>';
echo '<input type="submit" name="a" value="Search" style="margin-left:15px; margin-bottom:15px;">';
echo '</form>';


//show after drop down value is selected
if(isset($_POST['a'])){
//echo "zeeshanaslamdurrani". "<br>";

echo do_shortcode('[ujicountdown id="Photos Contest" expire="2015/04/30 00:00" hide="true" url="" subscr="sdf" recurring="" rectype="second" repeats=""]');
global $wpdb;
//get current competition value
$cat =$_POST['category'];
$comp = $wpdb->get_var("SELECT competition FROM competition ORDER BY cid DESC LIMIT 1");
//echo $comp;

$comp = $wpdb->get_var("SELECT competition FROM competition ORDER BY cid DESC LIMIT 1");
echo "current competition is ". $comp;


$sqll = "SELECT articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title, Sum(zvotes.zvotes) AS votessum FROM articles LEFT JOIN zvotes on articles.aid=zvotes.aid WHERE articles.category = '$cat' && articles.competition = '$comp' GROUP BY articles.aid, articles.username, articles.competition, articles.path, articles.category, articles.title ORDER BY votessum";

$results = $wpdb->get_results($wpdb->prepare($sqll)) or die(mysql_error());

foreach( $results as $result ) {
echo '<form action="" method="post">';
echo "<input name='category' type='hidden' value='$result->category'>";
echo "<input name='id' type='hidden' value='$result->aid'>";

echo $result->title.'<br>';
echo "<img src='$result->path' width='150' height='150' >" . '<br><br>';
echo $result->body.'<br>';
echo "<input name='comp' type='hidden' value='$result->competition'>";
echo $result->username.'<br>';

echo $result->votessum.'<br>';
echo "<input style='margin-bottom:30px;' value='vote' name='submit' type='submit'/></form>";

}//end of foreach




}//end of isset


My page enter image description here


After vote(which is a form submit button) is pressed once enter image description here


Error on second pressing vote button second time after page refresh enter image description here


votes table enter image description here


Articles table (articles table has 1 to many relationship with votes table) enter image description here


All my wordpress pages are redirecting to xampp's homepage

ok...i desparately need help with this...


I have a local xampp stack setup for my wordpress site. It was first installed on another webserver(clients webserver) and im doing work on it locally. So I downloaded all the files and database to my local xampp server. So here is what i did to run it locally to begin with:



  1. first I changed the url in the database table: wp_options for the siteurl.


  2. Then I added these two lines of code to the end of my wp-config:


    define('WP_HOME','http://localhost/wpsite'); define('WP_SITEURL','http://localhost/wpsite');




Those are the only changes i made to run it locally. Also, in the root of the wordpress site folder, there is this .htaccess file:



# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


I have tried all options:



  1. commenting out all combinations of the wp-config.php file's define lines.

  2. deleting the .htaccess file with combinations of all the define lines in wp-config.php file.


PLEASE HELP ME!


Moving JavaScripts from WordPress Template Header to Footer

I need some help moving the JavaScripts from the header to the footer.


`/library/js/jquery.uniform.min.js" type="text/javascript">


/library/js/jquery-ui-1.8.14.custom.min.js" type="text/javascript"> /library/js/jquery.xml2json.js" type="text/javascript">

/library/css/uniform.default.css" type="text/css" media="screen" charset="utf-8" /> /library/css/ui-lightness/jquery-ui-1.8.14.custom.css" type="text/css" media="screen" charset="utf-8" /> `


So the reason it's not loading is because WP executes it's standard JS scripts at the bottom of the page, while the form there has it in the middle of the page, so the scripts it depends on aren't loaded when they try to execute, and thus the form can't render. Please help us move them to the bottom.


If WooCommerce Stock Updates, Also Update Specified Field Values

I would like to have a function that should update the Est. Dispatch Date Field ) in whenever WooCommerce Stock Value / Stock Amount changes even when order is placed and stock amount is reduced by woocommerce.


I am unable to achieve this since I am unable to get variations ids and there stock amounts, based on which it should also update that variation's est. dispatch date field as below:


SCENARIO 1: http://ift.tt/1DrMEwJ


SCENARIO 2: http://ift.tt/1biGTvg


The Est. Dispatch date field is different for each variation ID. Likewise for the 1st variation, its name is cuzd-prod-general-v1, for the 2nd its cuzd-prod-general-v2 and so on for every product's variation.


I would like to place this code into my functions.php file to work. Please help. Thanks.


onload doesn't work in wordpress

I created a form generated by the crm I'm using in order to find the form input in the crm. Then I pasted the code on wordpress. It works ok. Then I added a datepicker on some field and tested all of it in local. It still works ok. When I upload all the necessary on wp it doesn't work anymore.


I did some test. Here some of them:


I added the function onload to the body of the template in the file header.php but, even if in the source page there is the onload function, the datepicker doesn't show up.


I tried to write the javascript code inside the page but it doesn't work.


I tried to write < script>function-name()< /script> after the div and it is still working on local but not on wordpress.


I was afraid the problem was that my page couldn't load the file by the relative path so I used the absolute one. Nothing changed.


Eventually I tried to use the absolute path on the local file and it is still working.


The last thing I thought was: My template is ignoring the javascript. But then I realized that in the same page there are 2 other functions and they are working properly.


Here is the code, maybe we can modify that in order to achieve my aim.



<div id='crmWebToEntityForm' align='left' >
<META HTTP-EQUIV='content-type' CONTENT='text/html;charset = UTF-8'>

<form action='https://************/crm/WebToContactForm' name=**************************** method='POST' enctype='multipart/form-data' onSubmit='javascript:document.charset="UTF-8"; return checkMandatery()' accept-charset='UTF-8'>
<input type='text' style='display:none;' name='xnQsjsdp' value='*************' />
<input type='hidden' name='zc_gad' id='zc_gad' value='' />
<input type='text' style='display:none;' name='xmIwtLD' value='*****************' />
<input type='text' style='display:none;' name='actionType' value='Q29udGFjdHM=' />
<input type='text' style='display:none;' name='returnURL' value='*************************************' />
<input type='text' style='display:none;' maxlength='20' name='CONTACTCF7' value='Applicant'/>
<div id="cf-two-columns">
<div id="left">
<p>First Name *<br /><input type='text' style='width:250px;' maxlength='40' name='First Name' /></p>

<p>Last Name *<br /><input type='text' style='width:250px;' maxlength='80' name='Last Name' /></p>
<p>Date Of Birth *<br /><input id="datepickr" readonly="readonly" type="text" style="width:250px;" maxlength="20" name="Date of Birth" placeholder="dd/MM/yyyy"></p>



<p>Email *<br /><input type='email' style='width:250px;' maxlength='40' name='Email' /></p>
<p>Phone *<br /><input type='text'style='width:250px;' maxlength='50' name='Phone' /></p>
<p> * These fields are required <br /></p>
</div>
<div id="right">
<p>Address* <br /><input type='text' style='width:250px;' maxlength='250' name='Mailing Street' /></p>
<p>Suburb or city* <br /><input type='text' style='width:250px;' maxlength='30' name='Mailing City' /></p>
<p>Postcode* <br /><input type='text' style='width:250px;' maxlength='30' name='Mailing Zip' /></p>
<p>Country* <br />
<select style='width:250px;' name='Mailing Country'>
<option value='Select One'>Select one</option>
<option value='Afghanistan'>Afghanistan</option>
<option value='Albania'>Albania</option>
<option value='Algeria'>Algeria</option>

</select>
</p>
<p>State* <br />
<select style='width:250px;' name='CONTACTCF9'>
<option value='Select One'>Select one</option>
<option value='Western Australia'>Western Australia</option>
<option value='New South Wales'>New South Wales</option>
<option value='Queensland'>Queensland</option>
<option value='ACT'>ACT</option>
<option value='South Australia'>South Australia</option>
<option value='Northern Territory'>Northern Territory</option>
<option value='Off Shore'>I am outside Australia</option>
</select>
</p>

</div>
<div id="right1">
<p>Current VISA*<br />
<select onchange="showDiv(this)" id="CONTACTCF1" style='width:250px;' name='CONTACTCF1'>
<option value='Select One'>Select one</option>
<option value='Bridging'>Bridging</option>
<option value='DeFacto'>DeFacto</option>
<option value='Partner'>Partner</option>
<option value='Permanent'>Permanent</option>
<option value='Sponsored'>Sponsored</option>
<option value='Student'>Student</option>
<option value='Tourist'>Tourist</option>
<option value='Working Holiday'>Working Holiday</option>
<option value='2 Working Holiday'>2 Working Holiday</option>
<option value='Business application'>Business application</option>
</select>
</p>

<p id="hide" style="display: none;">VISA Expiry Date *<br /><input readonly type='text' id="CONTACTCF81" style='width:250px;' maxlength='20' name='CONTACTCF81' placeholder='dd/MM/yyyy' />
</p>


<script>
function showDiv(elem){
if(elem.value == 'Bridging') {
document.getElementById('hide').style.display = "none";
} else if(elem.value == 'Select One') {
document.getElementById('hide').style.display = "none";
}
else {
document.getElementById('hide').style.display = "block";
}
}
</script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

<p>Passport Number *<br /><input type='text' style='width:250px;' maxlength='15' name='CONTACTCF2' /></p>
<p>Passport Expiry Date *<br /><input readonly id="datepickr2" type='text' style='width:250px;' maxlength='15' name='CONTACTCF84' placeholder='dd/MM/yyyy' /></p>
<p>Nationality *<br /><input type='text' style='width:250px;' maxlength='20' name='CONTACTCF3' /></p>
</div>
<div id="right2">
<p>Passport Upload *<br /><input type='file' name='theFile'></input></p>
<br>
<p>Enter this code<br /></p>
<p><img id='imgid' style="border:1px solid black;" src='*****************************************'>
<a href='javascript:;' onclick='reloadImg()'>Reload</a></p><br />
<p><input type='text' style='width:250px;' maxlength='80' name='enterdigest' /></p><br />
<p><input class="wpcf7-submit" style='font-size:12px;color:black' type='submit' value='Submit' /> </p>
</div>
</div>
<script>
var mndFileds = new Array('First Name', 'Last Name', 'Email', 'Phone', 'Date of Birth', 'Mailing Street', 'Mailing City', 'Mailing Zip', 'Mailing Country', 'CONTACTCF2', 'CONTACTCF3', 'CONTACTCF81', 'CONTACTCF1', 'CONTACTCF84', 'CONTACTCF9');
var fldLangVal = new Array('First Name', 'Last Name', 'Email', 'Phone', 'Date of Birth', 'Mailing Street', 'Mailing City', 'Mailing Zip', 'Mailing Country', 'Passport Number', 'Nationality', 'Visa Expiry Date', 'Current visa', 'Passport Expiry Date', 'State');
function reloadImg() {
if (document.getElementById('imgid').src.indexOf('&d') !== -1) {
document.getElementById('imgid').src = document.getElementById('imgid').src.substring(0, document.getElementById('imgid').src.indexOf('&d')) + '&d' + new Date().getTime();
} else {
document.getElementById('imgid').src = document.getElementById('imgid').src + '&d' + new Date().getTime();
}
}
function checkMandatery() {
var name = '';
var email = '';
for (i = 0; i < mndFileds.length; i++) {
var fieldObj = document.forms['WebToContacts1328094000000077001'][mndFileds[i]];
if (fieldObj) {
if (((fieldObj.value).replace(/^\s+|\s+$/g, '')).length == 0) {
alert(fldLangVal[i] + ' cannot be empty');
fieldObj.focus();
return false;
} else if (fieldObj.nodeName == 'SELECT') {
if (fieldObj.options[fieldObj.selectedIndex].value == '-None-') {
alert(fldLangVal[i] + ' cannot be none');
fieldObj.focus();
return false;
}
} else if (fieldObj.type == 'checkbox') {
if (fieldObj.checked == false) {
alert('Please accept ' + fldLangVal[i]);
fieldObj.focus();
return false;
}
}
try {
if (fieldObj.name == 'Last Name') {
name = fieldObj.value;
}
} catch (e) {}
}
}
try {
if ($***) {
var firstnameObj = document.forms['WebToContacts1328094000000077001']['First Name'];
if (firstnameObj) {
name = firstnameObj.value + ' ' + name;
}
$***.salesiq.visitor.name(name);
var emailObj = document.forms['WebToContacts1328094000000077001']['Email'];
if (emailObj) {
email = emailObj.value;
$***.salesiq.visitor.email(email);
}
}
} catch (e) {}
}
</script>
</form>

</div>

<script src="http://ift.tt/1GRLguc"></script>
<script>
var myCalendar;
function doOnLoad() {
myCalendar = new dhtmlXCalendarObject(["datepickr","CONTACTCF81","datepickr2"]);
}
</script>


HERE is also a live preview.


Thank you in advance to everyone who will try to help. DD


How can I use RecordJs in Wordpress

I need to create a page in wordpress with an audio recorder, after this audio be recorded, I need to send it by mail to me.


know I can record audio with the recorderjs javascript library.


GitHub RecorderJs


However I'm not getting implement the example link above


is possible to use RecordJs for this in wordpress? is there any other way? You guys know any free plugin for wordpress with this audio recorder?


Wordpress: Form Tempalte redirection

I have created a template for form validation and when i run it error says EPIC 404...article not found....I dont know anything about Wordpress so anyone can sort it out how to validate my custom form



<?php
if(isset($_POST['submit']))
{

$fullname=$_POST['fullname'];
$age=$_POST['age'];
$email=$_POST['email'];

if(!empty($fullname) && !empty($age) && !empty($email))
{
$dbc=mysqli_connect('localhost','root','root','wordpress');
$query="SELECT * FROM wp_mypage WHERE email='$email'";
$result=mysqli_query($dbc,$query);
$data=mysqli_fetch_array($result);
$val=mysqli_num_rows($data);

if($val==0)
{
$query="INSERT INTO wp_mypage ('$fullname','$age','$email')";
mysqli_query($dbc,$query);
header("Location : http://localhost/wordpress/?page_id=67");
}
else
{
$status='Already Subscribed';
header("Location : http://localhost/wordpress/?page_id=73");
}
}
else
{
$status='Please fill all the fields';
header("Location : http://localhost/wordpress/?page_id=73");
}
mysqli_close($dbc);
}
?>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" >
Name
<input id="name" name="name" type="text" required>
<br>Age
<input id="name" name="age" type="number" required>
<br>Email
<input id="email" name="email" type="email" required>

<input type="submit" value="Submit" />
</form>


I dont know whether to use $_SERVER or redirect to the page-id...


Galleria Galleries Not Loading Correctly After Infinite Scroll

I have a website built on WordPress with a couple of hundred posts. Each post contains up to 10 images. Infinite Scroll is used to load in more posts automatically. What I want is for the main page to be a page of image galleries; one per post.


Here is what I have:


First, I add the galleries in the post loop. I use the post ID to create a unique Galleria ID. I also use a second class name to pass the image ratio to the JS (sure there is a better way?):



<div id="galleria-1609" class="galleria 0.5">
<a href="img01-800x400.jpg" alt="Large Image" ><img src="thumb.png" /></a>
<a href="img02-800x400.jpg" alt="Large Image" ><img src="thumb.png" /></a>
</div>


...and then the javascript is added...



<script>
Galleria.run('#galleria-1609', {
thumbnails: 'numbers',
height: 0.5, /* ratio */
preload: 1
});
</script>


This works fine for the first set of Galleries but when infinite scroll loads more posts, the javascript is stripped. After some searching I found Infinite Scroll has a callback function with access to the Array of new elements.


So I tried this code in a function called from the infinite scroll callback:



function loadSliders(arrayOfNewElems) {
$(arrayOfNewElems).each(function( i ) {
var newGal = $(this).find('.galleria');
//extract ratio from 2nd class name:
var ratio = $(newGal).attr('class').split(' ')[1];
var thisID = '#'+ $(newGal).attr('id');

Galleria.run(thisID, {
thumbnails: 'numbers',
height: ratio,
preload: 1
});
});
}


This does load one more set of Galleries, but fails after with this error:


TypeError: $(...).attr(...) is undefined


Any ideas on why I am getting this error or better ways to achieve this?


Automatic configure wordpress IP on EC2

I have installed a LAMP server on an EC2 instance. Then I created an AMI so that I can easily spin up instances in the future.


Today I went back to spin up one such instance, and to my surprise the IP in the configuration is wrong. Basically when I first installed the LAMP server, Wordpress detected the IP and configured accordingly. Now on the instance that I launched today the IP is different, but the configuration for the previous IP is still there.


Now, I know how to change Wordpress IP. My question is: How can I make this step automatic when I launch an EC2 instance from an AMI?


Thanks


Highlight Non-breaking spaces in HTML page or WordPress editor

While editing in WordPress, I sometimes use non-breaking spaces in headers so that words stay together. When I save, the non-breaking spaces are there, but they look like normal spaces, so I can't see them. Also, WordPress creates non-breaking spaces when I type in the body of my post, which I have to remove somehow.


I thought it'd be easy to create a bookmarklet that uses jQuery to highlight non-breaking spaces in a web page or the editor. However, I'm no good with regular expressions, or maybe there's something else I'm doing wrong. Here's the jQuery code:



$('p').html($('p').html().replace(/ [\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]/g, '<span class="red">&nbsp;</span>'));


Here's a jFiddle: http://ift.tt/1cLc572


========


Maraca helped me out here (see below). I created the bookmarklet with his code, and added a white-space:nowrap to the span so that you can still see the highlight if it’s at the end of a line. Here it is:



javascript:function%20escapeRegExp(e){return%20e.replace(/([.*+?^=!:${}()\]\[\/\\])/g,"\\$1")}function%20replaceAll(e){return%20e.string.replace(new%20RegExp(escapeRegExp(e.search),"g"),e.replace)}jQuery("body").html(replaceAll({string:jQuery("body").html(),search:"&nbsp;",replace:'<u%20style="background:#FF0;white-space:nowrap">%20</u>'}));


Remember, it relies on jQuery already being loaded on the page. It doesn't play nice with the WordPress backend, but it works on the frontend and that's good for me right now. Hope someone else finds this useful too.


JQuery: Change image on page based on class in body

I have a wordpress page where I want to display a featured image on the header of the homepage, but no other pages. I set up a script to read whether the body tag contains the "home" class and display an image based on that. The code looks like this:



<script>
if($('body').hasClass("home")) {
$('#headshot').html('<img src="http://ift.tt/1Ivq4rA" alt="headshot">');
}
</script>


What's wrong with this script?


Different Wordpress Featured Image Overlay Effect

I have a grid of images (created by the featured image of each posts) and would like to have a hover effect applied to each image.


I would like it to display the title of the post with a coloured overlay. The entire image is overlaid/replaced with a coloured background with the post title contained within the image box.


The big thing is though, I would like there to be different coloured backgrounds for each post.


current code



<div class="single-featured-image">

<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>

<?php if ( has_post_thumbnail()) : the_post_thumbnail('full'); endif; ?>

</div>


with the css trying to change the post h2 tag to fill the space of the thumbnail (using margin/padding )


Not working to say the least


How do I create a while loop within a PHP string?

I am creating a query using shortcodes ultimate lightbox. But the only way this will work within a regular php page, is to save the data as string. So what I need to do is to create my query but somehow get my results within a string.


Here is what works before I use any kind of php query:



<?php
$my_tabs = "<ul class='easybuttons'>
<li>[su_lightbox type='inline' src='#lightbox1']AT&amp;T[/su_lightbox]</li>
<li>[su_lightbox type='inline' src='#lightbox2']Sprint[/su_lightbox]</li>
<li>[su_lightbox type='inline' src='#lightbox3']T-Mobile[/su_lightbox]</li>
</ul>";

echo do_shortcode( $my_tabs );
?>


but I need the ATT, Sprint, T-Mobile to be dynamic. Keep in mind the shortcode will only work if it within a string.


So how can I do a while loop within this string? I tried using an operator but did not work.



$args = array('post_type' => 'services', 'category_name' => $childid, 'order_by' => 'the_title', 'order' => 'ASC');

query_posts($args);

// The Query
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
$my_tabs .= '<ul class="easybuttons">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$my_tabs .= '<li>[su_lightbox type="inline" src="#lightbox1"]' . get_the_title() . '</li>';
}
$my_tabs .= '</ul>';
}
/* Restore original Post Data */
wp_reset_postdata();

echo do_shortcode( $my_tabs );
?>


UPDATE:


I tried using this code but it does work. Nothing comes through. I don't get any errors but no shortcode is displayed.



<?php
$args = array('post_type' => 'services', 'category_name' => $childid, 'order_by' => 'the_title', 'order' => 'ASC');


// The Query
$the_query = new WP_Query( $args );

// The Loop
if ( $the_query->have_posts() ) {
$lid = 1;
$my_tabs .= '<ul class="easybuttons">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$my_tabs .= '<li>[su_lightbox type="inline" src="#lightbox' . $lid . '"]' . get_the_title() . '</li>';
$lid++;
}
$my_tabs .= '</ul>';
}

echo do_shortcode( $my_tabs );
wp_reset_postdata();

Change a php file path in Wordpress

I am working on a wordpress plugin, i have an external php file that i need to use It should be placed in the Wp directory "http://localhost/forever/" (where my wp files are uploaded). For some reason i need to put this php file in an other folder but it should act like it's in Wp directory like changing its real path. any help is appreciated.thanks


WP_Query with OR conditions

Here is an issue, I have a site that has sort of complex search. I have set several arguments: s, meta_query, tax_query and post_type


Obviously these are all linked with AND relationships (except meta_query and tax_query that can be set with OR relationship, but I need to get posts that have entered phrase at either title or content or some of meta values, or some of taxonomies.


Any way of doing so?


Multiple AddAction 'init' in shortcodes.php

I'm modifying a wordpress plugin and adding a second form to the shortcode page. Problem is that both forms seem to be processed by the same function. I know the problem might be because I have two 'init' actions but wondering how this could be fixed.



// **********
// first form
// **********

add_shortcode('first-submit', 'cp_first_form');

function cp_first_form($atts, $content = null) {
// html form
}

function cp_first_form_submit_post(){
// code to process first form on submit
}

add_action('init','cp_first_form_submit_post');

// ***********
// second form
// ***********

add_shortcode('second-submit', 'cp_second_form');

function cp_second_form($atts, $content = null) {
// html form
}

function cp_second_form_submit_post(){
// code to process second form on submit
// strangely, it seems both forms get processed by this function after submit.
}

add_action('init','cp_second_form_submit_post');

Creating a Wordpress theme from a template

I'm new to coding for Wordpress and am trying to learn how to make themes. I'm looking to create (or basically use and modify) a free theme, which appears to be more of a template, that I found (http://ift.tt/WrdQOo) but I'm struggling to find out how to go about it.


Could someone please give me some pointers or a good tutorial? I'll gladly accept any help I can get. Thank you so much in advance!


I am getting unwanted null with my json output in json-api wordpress

I am new in wordpress and using Json-Api in wordpress for web-services, and i have create my own service in json-api/controllers/core.php file my function is:



<?php
public function get_blogs(){
global $json_api;
$categories = $json_api->introspector->get_categories($args);
echo "[";
foreach($categories as $cat){
if($cat->id == "5432"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5433"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5439"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5444"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5440"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5438"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5430"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5435"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5436"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5434"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5441"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5445"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5431"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5437"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "203"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5442"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5447"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "530"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}".",";
}
if($cat->id == "5443"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost,JSON_PRETTY_PRINT);
echo $catnow;
echo "}".",";
}
if($cat->id == "5448"){
$catPost = get_posts('cat="$cat->id"&posts_per_page=4');
echo "{"."\"category_title\":\"$cat->title\"".",\"category_id\":\"$cat->id\"".",\"posts\":";
$catnow = json_encode($catPost);
echo $catnow;
echo "}";
}

}
echo "]";
}


after that when i am getting its output as i want ,one null is extra added in json after finish my json output "]null" in last, please help.


Wordpress Ajax for logged in user fails

I am using wordpress 4.1.1. wp-admin and other several pages (like login, register...) use https connection. My goal is create ajax request for adding tickets to system.


So I can not call function for logged in user it calls function for not-logged in user. But when I add https for this page it`s work fine for me.


Question:


How I can keep user logged in on https and http, so is_user_logged_in() in amin-ajax.php works fine?


Wordpress: How to exclude users with default avatar from displaying

I have set default avatar in Wordpress settings if user didn't upload any of his own.


Question: How to exclude users with default avatar from displaying?


Update: I'm using in php code get_avatars func and was wondering how to exclude users with no avatars.


Wordpress custom form/feature

What is the best practice to create a custom form/feature in Wordpress? Things I'll use: jQuery, noUiSlider, Twitter Bootstrap.


Basically I will make a custom form, add some sliders to it and show results from the form inputs based on ajax.


How do I include noUiSlider etc? And where do I write my code? I will need to write html, css and javascript code.


Inserting data into a WordPress table on form submit, using PHP

I have a form with some fields, and a wpdb table which corresponds to the fields. I want the data from the form to be submitted into the table when the submit button is clicked on the form.


Here is the form:



function display_form(){
echo '
<form action="insertrow.php" method="post">
<p>Ticket id: <br />
User id: <br />
Description: <textarea class="widget" rows="4" cols="1"
name="ticket_description"></textarea>
Priority: <select name="ticket_priority" placeholder="Select">
<option value="critical">Critical</option>
<option value="urgent">Urgent</option>
<option value="important">Important</option>
<option value="standard" selected>Standard</option>
</select>
Status: <select name="ticket_status" placeholder="Select">
<option value="planned">Planned</option>
<option value="in progress">In Progress</option>
<option value="on hold">On Hold</option>
<option value="completed">Completed</option>
<option value="ready for invoice">Ready for Invoice</option>
<option value="to be invoiced as per attached">To be invoiced as per
attached</option>
</select>
</p>
<input type="submit" name="submit" value="submit">
</form>
';
}


the form calls the insertrow.php file:



if(isset($_POST['submit']))
{
insert_row();
}

function insert_row()
{
global $wpdb;
require_once('../../../wp-config.php');
$tablename = 'st_support_ticket';

$data = array(
'ticket_id' => '1',
'ticket_user_id' => '1',
'ticket_description' => $_POST['ticket_description'] ,
'ticket_priority' => $_POST['ticket_priority'],
'ticket_status' => $_POST['ticket_status'] );

$wpdb->insert($tablename, $data);
}


Just trying to get this to enter the description, priority and status into the st_support_ticket table.


At the moment when I click submit the url suffix changes to insertrow.php and displays a blank page. The data is not entered into table (checking by opening it up in phpmyadmin).


Am I missing something?


Wordpress displays content of my php.ini file on every pages

I'm facing a real problem that i've never seen before.. I could'nt find any post on this subject on any help forum. So please help me if you encountered this thing !! :)


Let me explain: I'm hosting a wordpress site at 1and1.com on a mutualized hosting. All is up to date (wordpress and all plugins installed) The problem is that it shows twice the content of my php.ini file on the top of every pages of my site. Here is the text displayed:



upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 128M
upload_max_filesize = 64M
post_max_size = 64M
memory_limit = 128M


It appears just after the BODY opening tag.


I managed to solve the problem once last week by deleting the php.ini file but it seems that it has been recreated automatically because the problem appears again today.


EDIT: I found that only php.ini files located in the 2 following directories are displayed: /wp-content/plugins/js_composer/include/autoload/params /wp-content/plugins/js_composer/include/autoload/vendors They are directories from the plugin : Visual Composer It seems to include every files located in that directory without any distinction between .php or any other extension or name. Is it a normal behavior?


Does anyone has information about this? Or just a direction to search?


Thank you very much for any idea!


How to get admin dashboard widgets?

I want to replace my default wordpress admin dashboard. How can I get all dashboard widgets?


Dashboard Widgets API Documentation explains to use get_option. But this option doesn't exist in my case (so it just returns (bool) false - I'm confused.



get_option( 'dashboard_widget_options' )


What I basically want to get is the content + tile of each widget to build my own overview of widgets.


Datepicker and custom contact form (custom wp plugin)

thank you for the help in advance. I have been trying to find tutorial about building my own contact form for wordpress (without plugin). I thought i found one (part of the question).



<?php
/*
Plugin Name: Self Catering Contact form plugin
Plugin URI: http://example.com
Description: Simple non-bloated WordPress Contact Form use [contact_form]shortcode
Version: 1.0
Author: Agbonghama Collins
Author URI: http://w3guy.com
*/


function html_form_code() {
echo '<form action="' . esc_url( $_SERVER['REQUEST_URI'] ) . '" method="post">';
echo '<p>';
echo 'Your Name (required) <br />';
echo '<input type="text" name="cf-name" pattern="[a-zA-Z0-9 ]+" value="' . ( isset( $_POST["cf-name"] ) ? esc_attr( $_POST["cf-name"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Your Email (required) <br />';
echo '<input type="email" name="cf-email" value="' . ( isset( $_POST["cf-email"] ) ? esc_attr( $_POST["cf-email"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Subject (required) <br />';
echo '<input type="text" name="cf-subject" pattern="[a-zA-Z ]+" value="' . ( isset( $_POST["cf-subject"] ) ? esc_attr( $_POST["cf-subject"] ) : '' ) . '" size="40" />';
echo '</p>';
echo '<p>';
echo 'Your Message (required) <br />';
echo '<textarea rows="10" cols="35" name="cf-message">' . ( isset( $_POST["cf-message"] ) ? esc_attr( $_POST["cf-message"] ) : '' ) . '</textarea>';
echo '</p>';
echo 'Select date <br />';
echo '<p><input type="text" id="datepicker" name="datepicker" value="' . ( isset( $_POST["datepicker"] ) ? esc_attr( $_POST["datepicker"] ) : '' ) . '" size="40" />'.'</p>';
echo '<p><input type="submit" name="cf-submitted" value="Send"/></p>';
echo '</form>';
}
function deliver_mail() {

// if the submit button is clicked, send the email
if ( isset( $_POST['cf-submitted'] ) ) {

// sanitize form values
$name = sanitize_text_field( $_POST["cf-name"] );
$email = sanitize_email( $_POST["cf-email"] );
$subject = sanitize_text_field( $_POST["cf-subject"] );
$message = esc_textarea( $_POST["cf-message"] );
$datepicker = sanitize_text_field($_POST["datepicker"]);

// get the blog administrator's email address
$to = 'atesz@atesz.co.uk';

$headers = "From: example@yourdomainname.com" . "\r\n";

// If email has been process for sending, display a success message
if ( wp_mail( $to, $subject, $message, $headers ) ) {
echo '<div>';
echo '<p class="red">sent</p>';
echo '</div>';
} else {
echo 'An unexpected error occurred';
}
}
}
function cf_shortcode() {
ob_start();
deliver_mail();
html_form_code();

return ob_get_clean();
}

add_shortcode( 'contact_form', 'cf_shortcode' );


This is what my contact-form.php looks like. My first problem that it doesnt send the email - or it doesnt arrive even tho it says that the mail was sent. I have read a few things for example some hosting providers dont allow you to use different email address to your domain ones... Could somebody explain this?


If you still have enough patience left, could somebody guide me through how to implement datepicker (which i thought i have done), and how to handle or get the data from it to be included in the email?


Thank you very much for your time...


Safari appears to be ignoring CSS

I'm doing some changes to a wordpress theme, but Safari (both on Mac and iOS) seems to be ignoring some of the CSS, whereas other browsers work fine.


An example - this is how it looks in Chrome and Safari: http://ift.tt/1zxI9Qq


This is the CSS I've used, specifically for the images.



.homeleftside1 img {
width: 70px;
height: auto;
margin-right: 15px;
float: left;
border-radius: 100%;
}


I've got a test site here so you can see what I mean: http://46.101.9.172


Any ideas where I am going wrong? Thanks


Disqus manually sync when I click but not automatically. How do I fix it?

Disqus comment plugin has stopped automatic comment syncing with database. Now it only works when I click the manual sync button or run wp-cron.php on my browser.


I've tried couple of techniques, used cpanel cron, and also tried with wp-control plugin, but it didn't work. I was only able to make it work with manual syncing.


I contacted Disqus support but they referred me to their sync troubleshooting page what I've already tried. I'm not a big fan of using Alternate Cron since it adds a query every time in the url.


I haven't made any remarkable changes in the files between that time. And I asked my hosting provider HostGator who said everything is fine from the server side.


So is there any solution to make the automatic sync work? I'm very desperate about it.


My site is: http://ift.tt/1b5o7ki


AJAX/PHP POST retrieval

I'm doing a POST using AJAX and I'm checking for the response with PHP using


if (!empty($_POST)


but it doesn't seem to be hitting the if or else.


The form is submitting and I get a 200 status in the network tab.


PHP isn't my main language so I'm wondering if I'm missing something relatively simple?


Thanks


Form:



<form id="myForm" method="post" novalidate="novalidate">
...
<button type="submit" name="contact_send">Send</button>
</form>


AJAX:



jQuery.ajax({
type: 'POST',
url: window.location.href,
data: formData,
success: function(response) {
console.log('response');
}
});


PHP:



if (!empty($_POST)) {
print_r('Data');
add_action('init', 'deliver');
} else {
print_r('No Data');
}


Neither the if or else is reached


how do I Increase post width in wordpress blog

I've been trying to increase the width of the post container in my theme. The thing is that, I can't seem to get it working. I've tried editing my style.css, but it just doesn't work.


I have added a RIGHT sidebar via "STYLE" plugin.Everything seems fine. I have tried increasing the content widht.. didn't work. I've got a child theme, so, it's all good.


Here are the screen shots to my page :-


http://ift.tt/1Hjz30g


why wordpress loop behave diffrent on singl.php and archive.php

Why a wordpress loop show only one post on single.php whether shows many posts on archive.php. what is the reason of this behavior while we use the same loop for both.


Wordpress - one installation for multiple web sites

I have multiple website with different databases and different hosts. Is there a way to have one dashboard for all sites.


plugin first menu name different from first submenu using register_post_type

i made plugin where i had used "register_post_type" to create custom post taxonomy.


problem i that my first sub menu is also name of my plugin how can i fix it


Below i code


add_action( 'init', 'myofferlugin' );



function myofferlugin() {

$labels = array(
'name' => _x( 'My Plugin', 'offer' ),
'singular_name' => _x( 'Meno one', 'offer' ),
'add_new' => _x( 'Add New', 'offer' ),
'menu_name' => _x( 'My Plugin', 'offer' ),
);

$args = array(
'labels' => $labels,
'hierarchical' => false,
'supports' => array( 'title' ),
'menu_icon' => plugins_url('images', __FILE__).'/icon.png',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post'
);

register_post_type( 'offer', $args );
}

Ip address is not mine , but It was blocked and I cant open my website

have Problem with my domain regarding my Wordpress WEBSITE


When I am trying to open my website from my PC then I get below IP address , which is not mine . I neither use Proxy nor any tools . The message is displayed as below.


Your computer IP address 108.162.222.234 is listed at StopForumSpam database so your visit is blocked. You can unblock yourself by entering the following code:


---Captcha code is given here---


when I entered Right captcha of Image then It says "You have entered invalid captcha" and doesn't proceed ahead.


SO I want to know that somebody is trying Hacking or something else with my website ?


Automatic configure wordpress IP on EC2

I have installed a LAMP server on an EC2 instance. Then I created an AMI so that I can easily spin up instances in the future.


Today I went back to spin up one such instance, and to my surprise the IP in the configuration is wrong. Basically when I first installed the LAMP server, Wordpress detected the IP and configured accordingly. Now on the instance that I launched today the IP is different, but the configuration for the previous IP is still there.


Now, I know how to change Wordpress IP. My question is: How can I make this step automatic when I launch an EC2 instance from an AMI?


Thanks


Highlight Non-breaking spaces in HTML page or WordPress editor

While editing in WordPress, I sometimes use non-breaking spaces in headers so that words stay together. When I save, the non-breaking spaces are there, but they look like normal spaces, so I can't see them. Also, WordPress creates non-breaking spaces when I type in the body of my post, which I have to remove somehow.


I thought it'd be easy to create a bookmarklet that uses jQuery to highlight non-breaking spaces in a web page or the editor. However, I'm no good with regular expressions, or maybe there's something else I'm doing wrong. Here's the jQuery code:



$('p').html($('p').html().replace(/ [\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000]/g, '<span class="red">&nbsp;</span>'));


Here's a jFiddle: http://ift.tt/1cLc572


I'm open to other suggestions as well :-)


Page is Jumping back to Top after targeting the anchor tag

Hello guys im using wordpress and i need to jump to the comments when the user is clicking a link. The single.php is opening in a new tab and its loading the page on the anchor (comment-id) but after that its always jumping back to the top of the page.


I guess it could be a problem with javascript but im not sure and im not sure where to find it in wordpress single.php. Has anyone an idea how to prevent the page jumping back to the top after loading. So that i can stay at the comment after clicking the link on a different page?


this is the target <a name="comment'.$comment_ID.'" href="#comment'.$comment_ID.'" onclick="deletco('.$comment_ID.')">DELETE</a>


and this is the link form the other page to the target on single.php



<a href="'.$commpostlink.'#comment-'.$commentid.'" target="_blank">'.$titlecomm.'</a>


thanks for any help