samedi 28 février 2015

how to create text box in WP


How do I create a text box next to a picture in a blog? I am having problems lining up text and pictures in my blog the way I want it to look.





Garbled Code added to Email Field of 'Quick Edit' comment screen


when I edit a comment normally the email just contains the email like it should, but when I use 'quick edit comment' then there's code added in the email field after the email. This code to be specific:



/* <![CDATA[ */!function(){try{var t="currentScript"in document?document.currentScript:function(){for(var t=document.getElementsByTagName("script"),e=t.length;e--;)if(t[e].getAttribute("cf-hash"))return t[e]}();if(t&&t.previousSibling){var e,r,n,i,c=t.previousSibling,a=c.getAttribute("data-cfemail");if(a){for(e="",r=parseInt(a.substr(0,2),16),n=2;a.length-n;n+=2)i=parseInt(a.substr(n,2),16)^r,e+=String.fromCharCode(i);e=document.createTextNode(e),c.parentNode.replaceChild(e,c)}}}catch(u){}}();/* ]]> */


When I then save the comment using the 'quick edit' menu it's saved like this:


abc@gmail.comCDATAfunctiontryvartcurrentScriptindocumentdocument.currentScriptfunctionforvar


Which is unwanted behavior of course...


I tried disabling all my plugins and removing all custom code from function.php but the problem still persists...


Anyone have an idea what could be causing this?





Transfer Part of Multisite to new Domain


I have a multisite on my domain, and I only want to transfer the /support/ install of WordPress to a new domain. Since both installs of WP are combined in the database, how do I separate them so I can move the support site over?





How to give all CPT a folder automatically based on their slug


This is what I have now and working:



function get_custom_post_type_template($single_template) {
global $post;

if ($post->post_type == 'amazon') {
$single_template = TEMPLATEPATH . '/amazon/single.php';
}
return $single_template;
}
add_filter( 'single_template', 'get_custom_post_type_template' );


But I want something like this:



add_filter('single_template', 'my_single_template_folders_terms');
function my_single_template_folders_terms($template) {
global $wp_query;
foreach( get_post_type(array('public' => true, '_builtin' => false)) as $post_type ) {
if ( file_exists(TEMPLATEPATH . "/{$post_type->slug}/single.php") )
return TEMPLATEPATH . "/{$post_type->slug}/single.php";
}
return $template;
}


I got this error; Warning: Invalid argument supplied for foreach()





Is there any wordpress function to update a random post every 10 minutes?


I' m looking for a function which can be inserted in wordpress theme function.php , when inserted , i want it to update a random post (which is already posted ) every 10 minutes .


can this be done through cron job or by simple writing a php code in function.php.





How to make this clean?


I test on localhost



$MySITE = 'http://www.ciusan.com';

wp_editor($MySITE, 'CNB_Content', $settings = array('media_buttons' => false,) );


but on output always:



http://localhost/\"http://www.ciusan.com\"


How to become only:



http://www.ciusan.com




Why is converting my database to UTF-8 truncating entries?


I'm running WordPress 4.1.1. My site is hosted at NearlyFreeSpeech.


I've been using my WordPress blog since the days when it encoded information in the latin1 charset. This week, I realized that certain posts on my blog (like these: 1-2-3) weren't displaying Japanese characters--the characters either show up as question marks, or as strings of characters like 日本語.


Clearly, this is an encoding error. Looking at my database in phpMyAdmin, I have many tables and columns in my database with their collation set to latin1_swedish_ci. I sought to fix this by changing the database to UTF-8 in a variety of different ways. They all had the exact same result.


The ways I tried to change the database encoding to UTF-8:



  1. Use the UTF-8 Database Converter plugin

  2. Follow this guide to export the database, replace all instances of "latin1" with "UTF8"

  3. Use a SQL script to convert tables and columns to blob, and then to UTF-8 text (detailed here)

  4. Use a SQL script to recast tables and columns to the datatype they contain, then to blob, and then to UTF-8 text (detailed here)


Expected results:


My site appears the same as it was above, with all themes and settings intact, but now displaying Japanese characters properly.


Actual results for all of the above methods:


Japanese still doesn't display correctly. What's more, database entries end abruptly; for instance, some entries in post_content are missing some or most of their original content. Custom shortcodes, defined by the Shortcoder plugin and stored in the shortcoder_data row in wp_options, are broken because the shortcoder_data entry got abruptly truncated. My theme options, including custom CSS and fonts, appear to have been reset or damaged, most likely due to similar abrupt truncation of database entries.


Luckily, I had the foresight to make all these changes on a duplicate database, so I have a backup with all my data intact.


When I compare the altered data in post_content to the original, I notice something: nearly all of the truncated strings begin with a special character. For instance, a post that once read:



Today it was a pleasant 72° and sunny.



will, in the altered database, read:



Today it was a pleasant 72



I haven't gone through and found all of my truncated posts--I know nothing about mySQL, so I'd have to do that by hand, and that would be an exercise in patience. However, out of a sample of 8 posts that got truncated, 6 of them were clearly truncated at a special character.


What do I need to do to properly convert my database so that Japanese characters display correctly without causing this data loss--or, barring a complete solution, what can I do to properly diagnose what's going on?


Thank you.


Update: Extra information


A few more things.


I used to have a lot of posts on my blog that displayed strings like I’m instead of I’m, naïve instead of naïve. Like I mentioned above, Japanese was displaying as long strings like 日本語 instead of 日本語. I went through and replaced these strings where I saw them, replacing ï with a proper ï (for instance).


I didn't catch all of them, however, and there are a few posts in my database that still have naïve instead of naïve.


When I look at those posts on the databases I've altered... they display correctly. They don't truncate. All of the garbled characters have seamlessly translated into their "proper" equivalents. Even the Japanese converted.


In the posts where I went back and "corrected" the garbled characters, however, where I have naïve and not naïve, the content in the database gets truncated on import as described above.





How can I force a specific password?


How can I force a specific password for a specific user & not let that user change their password? I have a client that thinks that even if I force strong passwords via this plugin: http://ift.tt/1LkCJ3z their users will use short & easy passwords. Thus, they want to set random 14 character passwords for every user & not let them change said passwords. Does anyone know how to do this?





How to create a CSV on the fly and send as an attachment using wp_mail?


I'm trying to create a CSV file from a form submission and send that file automatically by email to a specific user. The email itself is sending fine, but I can't get the attachment to go through. Is it possible to create an attachment without first saving the file to the server?



function create_csv() {
$fd = fopen('php://temp/', 'w');
if($fd === FALSE) {
die('Failed to open temporary file');
}

$records = array( array('dummy', 'data', 'found', 'here') );

fputcsv($fd, $headers);
foreach($records as $record) {
fputcsv($fd, $record);
}

rewind($fd);
$csv = stream_get_contents($fd);
fclose($fd);
return $csv;
}

$to = $email;
$subject = 'Subject';
$message = 'Message';
$headers = 'From: ' . $other_email;
$attachment = create_csv();

$sent = wp_mail($to, $subject, $message, $headers, $attachment);




Hide a div to Fade_in another one ( the_content) for custom post type


I'm having few problem with my jquery . ..


Here is my situation:


i've create a custom post type, which wokrs perfectly. Outside my ul li, I have an image on the side.


on click of the title of the archive of my custom post type, I'd like to hide this image,to fade in the_content of the post.


Then, If i click to the title of another "post" from the archive, to hide the_content previously open to display the new one, etc.


here is my archive:



<?php get_header(); ?>
<?php $mainID = $post->ID; ?>

<div class="content-wrap col-xs-12 col-sm-12 col-md-12 col-lg-12">
<main id="main" class="site-main" role="main">


<ul class="archive_ad">
<?php
global $wp_query;
$args = array_merge( $wp_query->query_vars, array( 'posts_per_page' => 50, 'category_name' => '' ) );
query_posts( $args );
while(have_posts()): the_post();
?>
<li>


<div class="single-featured-image">
<h2><a class="more_prod"> <?php the_title(); ?></a></h2>
<?php if ( has_post_thumbnail()) : the_post_thumbnail('full'); endif; ?>


<div class="second_image"><?php echo MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'close-up', get_the_ID(), 'thumbnail'); ?></div>
</div>
<div class="content_post"> <?php the_content(); ?></div>
</li>
<?php
endwhile;
wp_reset_query();
?>


</ul>


<div class="img_side">

<img src="mywebsite/man_ok.jpg" alt="">
</div>


</div>
</div>

<?php get_footer(); ?>


in the index.php I've add this jquery:



<script type="text/javascript">

$('.more_prod').click(function() {
var i = $(this).index();
$('.img_side').hide();
$('.content_post' + (i+1)).show();
});

</script>


in my css I've put the class of content_post in display:none


Nothing happen on click of the_title . ..


Any highlight .. would be awesome ! Thank you for your time !





Relative or dynamic site url possible?


I have a local Xampp wordpress installation that I am using as sort of an intranet with some people I work with. I require them to be able to access it on our LAN router -- I found that I needed to change the site url and links from http://localhost:8080 to my IP http://ift.tt/183qZmb for images and css to show.


However, I have found that when we are connected to a different router, or my travel router, this IP changes and obviously makes it not work on the LAN. I'm not really wanting to search/replace and change the site name every time a new computer and/or server is hosting the local site.


Question: So I'm really interested to see if there is a way to make the site/home URL dynamic to the hosting computer's current IP or computername. Or if I'm looking for the wrong type of solution.


I have searched extensively for a solution to this, but I feel my problem is I'm not sure what terms to search for -- or if there is a better solution. I hope someone smart could point me in the right direction.


-Based on my internet searches, I have tried a couple plugins - Relative URLs and "Root relative URLS" in hopes it would fix but it has not made a difference. -I have also set a static IP address in my travel router - however, the problem persists that I would need to change the ip address in the site if the computer changes. -I've also tried this in my wp-config:



<?php
define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
//add the next line if you have a subdirectory install
define('WP_SITEURL', WP_HOME . '/wordpress');




local folder permissions vs chown -- security considerations


I was trying to install a plugin, and I kept getting the following error:



Unpacking the package…

Could not create directory.



I'm on Localhost on a XAMPP stack on Mac OS X Yosemite.


The way I solved this was by changing the wp-content folder's permissions in Finder, so that everyone could write to not only the folder but also to all enclosed items.


Per the image below, I right clicked on (1), then changed (2) to "Read & Write" and then chose "apply to enclosed items" in (3).


The proper way to solve this would have been to give the correct user write permission to the wp-content folder by using the chown command.


I didn't use the chown command because (1) I'm still learning how to use it, and (2) it's not clear to me which user is supposed to be given permission to... whether it's the apache user or the ftp user (I'll figure it out eventually).


My question is, if I were to migrate this wordpress site to an online domain based on an Ubuntu server, what are the security implications of my having given everyone write access to this folder?


enter image description here





How set for each user owner images folder


I have 200 user in my site. and i need to hide all picture upload from user1 for all ether user when upload it from wp-admin-> media upload.


And if user50 upload new picture. So he only see it in media upload.


How can do that ?





How to enable reply button on mostly deeply-nested comments?


I have a blog on wordpress.com, using the Twenty Twelve theme.


Background


In my experience, on wordpress blogs with nested comments, the reply buttons only show on individual comments when their nesting level is above the maximum depth allowed. However, one can reply directly to any comment at any level when using the wordpress Android app. This can also be done via webgui by clicking the "reply to" link in a notification email, or by custom forming a ?replytocom URL.


Depending on their personal app/email settings, users may get notified of any replies to their comments.


If a user replies to a comment that was already at the deepest nesting level allowed, then the notifications operate as usual, but it will be displayed as a peer of its parent comment.


Questions


To start with, is all of the "background" above correct?


Is there a way to enable the reply buttons on all levels of comments?


If not, is there a known reason for the discrepancy in the interfaces?


Thanks.





get_avatar from user id


1 - I have two members witch settings are set to subscribers. 2 - I have made a page in wordpress with the code: Get_name 3. Now I want get the members avatar to that img and also the name to this page.


How do I do this, what do I have to do? I've tried to find a answer but I only see this:





erase post excerpt limitation [×]


i have a custom site in homepage have problem of post excerpt with max 35 word, now i want eliminate this limitation, after search in varius file the limitation and after individuate i have changed the (35) with big number, the post increase the number of caracter but on last have the dot (...) alternative of "readmore" now i want erase also this but not indivduate this, how eliminate this limitation ???


this site use advanced custom field and Custom Post Type UI version: 0.8.3


the home have 2 file


1) home 2 home video


this is a file : http://ift.tt/1LXC7OL!


thanks





Wp_Schedule_Event every day at specific time


I write Following code to run my function every day at 16:20 ..


But I guess is the problem in code..


not working


Epoch timestamp: 1427488800


3/28/2015 1:10:00 AM



if( !wp_next_scheduled( 'import_into_db' ) ) {
wp_schedule_event( time('1427488800'), 'daily', 'import_into_db' );

function import_into_db(){

////My code

}
add_action('wp', 'import_into_db');
}




$wpdb->replace / Replace or update primary key


I write code to save data in to the database table.


I want Replace a row in a table if it exists or insert a new row in a table if the row did not already exist.


http://ift.tt/tobmyc


I use $wpdb->replace function and then add $wpdb->insert_id to end of code.


For Update all fields , I using replace 'id' That is primary key.


I add the id field to array



$wpdb->replace( $wpdb->prefix . 'fafa',
array(
'id',
'title' => trim($row->item(0)->nodeValue) ,
'liveprice' => trim($row->item(2)->nodeValue) ,
'changing' => trim($row->item(4)->nodeValue) ,
'lowest' => trim($row->item(6)->nodeValue) ,
'topest' => trim($row->item(8)->nodeValue) ,
'time' => trim($row->item(10)->nodeValue) ),
array(
'%d',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s'
) );
$wpdb->insert_Id;




Why wp_mail() function isn't sending any emails and displaying '0' in Chrome 'Network' response


I'm trying to send emails through wordpress using wp_mail() function and it doesn't seem to work.


It's displaying 0 in Chrome 'Network' response with



Status Code:200 OK


this my code part:



// Contact form Ajax

add_action('wp_ajax_nopriv_submit_contact_form', 'submit_contact_form');

function submit_contact_form(){

if(isset($_POST['email'])) {

$email = $_POST['email'];
$email_to = "info@company.com";

$host = "ssl://smtp.gmail.com:465";
$username = 'myEmail@company.pro';
$password = 'passpass';

$email_subject = "You have a new email from $email via company.com website";
$message = $_POST['text'];

$headers = array ('From' => $email, 'To' => $email_to,'Subject' => $email_subject);
/*$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));*/

//$mail = $smtp->send($email_to, $headers, $message);

wp_mail( $email_to, $email_subject, $message );

/*if (PEAR::isError($mail)) {
echo($mail->getMessage());
} else {
echo("Message successfully sent!\n");
}*/
}
}





error_reporting(E_ALL);
ini_set("display_errors", 1);


What part might be wrong?


Edit:


This is the ajax part:



// Send button for the "contact form".
$('#sendBtn').click(function(){
//get info
var fullname = $("#fullname").val();
var email = $("#email").val();
var text = $("#text").val();

//send info to php
$.ajax({
beforeSend: function() {
if ( IsEmail(email) == false) {
$('#aboutUnsuccess').show("slow");
$('.form_content').hide("slow");
}
},
url: document.location.protocol+'//'+document.location.host+'/wp-admin/admin-ajax.php',
type: "POST",
/*action: 'submit_contact_form',*/
data: ({ "action": "submit_contact_form", "fullname": fullname, "email": email, "text": text }),
success: function (results){
if ( IsEmail(email) == true) {
//hide table
$('.form_content').hide('slow', function() {
$('.form_content').hide( "slow" );
});
//show textboxes
$('#aboutSuccess').show("slow");
$( "#aboutSuccess" ).append( "<iframe id=\"pixel-thing\" src=\"http://ift.tt/189wLCH\" width=\"1\" height=\"1\" border=\"0\"></iframe>" );

}
}
});


});




get_option function


I'm currently trying to make my own theme, but i'm not quite sure how the get_option() function works, because how come this..



echo get_option('show_header', 'sultenhest_theme_display_options');
echo get_option('sultenhest_theme_display_options')['show_header'];


..both returns 1 (but Dreamweaver doesnt like the second option). While



echo get_option('twitter', 'sultenhest_theme_social_options');


..simply returns 'sultenhest_theme_social_options', which is incorrect.


An option would be to define the array as such



$social_options = get_option( 'sultenhest_theme_social_options' );


and call it like this



echo $social_options['twitter'];


It returns the correct string, but it only works in the header.php (if the array is defined there) file and not in, e.g. footer.php.




UPDATE: Following partly ialocin and Brad Dalton i came up with this solution, which works like a charm:



function sultenhest($option, $arg){
$the_array = array();
foreach( get_option('sultenhest_theme_'.$option) as $key => $item ){
$the_array[$key] = $item;
}
return $the_array[$arg];
}


and echoing it out like this:



echo sultenhest('social_options', 'twitter') ? '<a href="' . sultenhest('social_options', 'twitter') . '">Twitter</a>' : '';




Recent post in the middle of the content


My site has a static front page and a blog.


I'm using the Foundation5 grid and I've split the content of the homepage onto three rows, like this, and I'm updating both the content and the html in the text-editor.



<page content 1st row>
<page content 2nd row>
<page content 3rd row>


My problem is that I want to split the first headline into two blocks. The one on the left is my page content and the one on the right should display the most recent blog headline + some other infos. Like this:



<page content 1st row><blog headline>
<page content 2nd row--------------->
<page content 3rd row--------------->


http://neverbland.com/ has a nice example of what I'm talking about (scroll to the very bottom of the page, the yellow block on the right).


Normally I would create a custom page template but in this case the php code would be right in the middle of my page content so I thought I'd use a plugin.


I downloaded and customized the Flexible posts widget to display the most recent post in a widget and then amr shortcode any widget to insert the widget as a shortcode in the middle of the page content (Flexible Posts Widget doesn't support shortcodes yet).


It works, but I'm using two plugins and I'm editing a few files just to display one headline, I'm wondering if there's a better approach. I'm sure I'm missing something. (I'm using the http://jointswp.com/ theme btw)





Add custom items in Breadcrumb NavXT


On my blog, I'm using Breadcrumb NavXT plugin. It works great.


On a specific portion of my site, I'd like to replace the normal breadcrumbs by custom ones. I have an array with the "parent" URLs, titles, and so on.


I don't understand how to "push" my informations into the plugin. My theme is only using this code :



if(function_exists('bcn_display')) {
bcn_display();
}


My wish is to remove the normal breadcrumbs and add mine, like a "virtual nagivation path".


Any leads ? Thank you very much !


Edit: I want to add items to $breadcrumb_navxt->breadcrumb_trail->breadcrumbs , from outsite of the plugin's class. breadcrumb_trail is protected, so I'm looking for a way.





Wordpress theme not recognized when using virtual directory (IIS)


I have clean WP 4.1 installation in a subdirectory.


The overall solution structure looks as follows:



application
plugins
themes
vendor
wordpress
index.php
wp-config.php
web.config


I serve it using IIS 7 on Windows 8.1.


My custom theme is located outside the solution root and I map it as a virtual directory into application/themes/mytheme.


All files inside mytheme folder are accessible:



http://localhost/application/themes/mytheme/style.css
http://localhost/application/themes/mytheme/screenshot.png
...


I've also tried allowing directory listing for http://localhost/application/themes/mytheme/.


But WordPress doesn't recognize it.


Where the problem could lie?




P.S. Also asked the same question on http://ift.tt/1AFL7pY





Switch to the library tab in the media uploader


I'm developing a plugin that adds a tab to the media uploader to add external videos to the media library via oembed. Everything works as expected but I need to switch to the library tab after adding a new external video via the new tab. This is part of the code I'm using:



wp.media.controller.Custom = wp.media.controller.State.extend({

initialize: function(){
this.props = new Backbone.Model({ custom_data: '' });
this.props.on( 'change:custom_data', this.refresh, this );
},

refresh: function() {
this.frame.toolbar.get().refresh();
},

customAction: function(){
wp.media.post( 'add-oembed', {
url: this.props.get('custom_data'),
post_id: wp.media.view.settings.post.id
});

this.frame.content.mode('browse');

}

});


The line this.frame.content.mode('browse') is supposed to make the switch to the library tab, but I'm getting an error message that says: TypeError: this.collection is undefined.


Any ideas?





Dynamic registration page for Event Espresso


Is it possible to customize an Event Espresso registration page, so that I can dynamically hide, or make visible, various question groups? If this is possible with a bit of programming, could you please explain, at a high level, what would be necessary?


I'd like the 1st question on the page to determine which question groups to display. Specifically, someone would choose whether they are signing up as an:



  • individual

  • member of a group

  • an entire family


Each one of those options would have a different set of question groups. I realize I could create separate events for each of those options and have a different registration page for each, but that is not an ideal solution.





How to have working breadcrumbs with several taxonomies associated with a custom post type


I have a breadcrumb / navigation problem. I don't know if it's possible to achieve what i want or if i can do it with mysetings or not.


I have a custom post type "Formation", for which i created 2 custom taxonomies : "Formation type" (formationtype) => hierachical "Formation public" (formationpublic) => non hierarchical


Formation type :



  • FT1

    • FT1.1

    • FT1.



  • FT2

    • FT2.1




And "formation public" public1, public2, ...


I want to have this menu links :


...



  • Formations (non clickable)

    • FT 1 (clickable)

    • FT 2 (clickable)




and when I click on FT 1, I have a page displaying a list of all formation of type FT1



  • FT11

    • formation1 of type FT11

    • formation2 of type FT11



  • FT2

    • formation1 of type FT12

    • formation2 of type FT12




And finally when i click on one of the formations : "formation1 of type FT11" i get the complete description of that formation.


So my goal is to be able to make a breabcrumb like :


<Home> / <Formation> / FT1


with the url : http://mydomain/formation/formation1-of-type-FT11 And


<Home> / <Formation> / <FT1> / <FT11> / formation1 of type FT11


With all the non final elements <...> being clickable to be able to navigate through the breadcrumb and not having to go back to the menu.


Since I create my lists with custom requests, if i use any breadcrumb tool, i only get something like : Home / FT1 (at best)


For the second type of taxonomy, I associate one or several terms from "formationpublic" (doctor, nurse, ...) to a formation, I have in the complete description of that formation :



  • formation1 of type FT11

  • Public : ,

  • Description ....


If i choose doctor, i have the list of all formation for doctors, but i choose from there a formation i loose the breadcrumb, it is different from the Formation type path. I have the url : http://mydomain/formation/formation1-of-type-FT11


So my question is what would you suggest as a structure to have "working" breadcrumbs as i (tried to) explain ? Thank you





How can i display submission data from a form on the front page/post?


I'm looking for a form plug in that allows me to input name,last name, email,phone and 1 question, and then display it on the front page/post of the site, i tried ninja forms, but it doesn't allow me to display data directly, do anyone knows a free form plugin that allows me to do this? this should work like an question& answer , the user trough the form fill his personal data and makes a question, the question is displayed on the website front page, the administrator can answer that question. that's the functionality i want to implement.


thanks in advance.





Moving website - admin section


I have successfully moved a wordpress site from /test directory to the root, so now the website url looks like www.example.com. Fine. However the admin section (wp-admin) still points to /test directory and so the url looks like http://ift.tt/1AmSvBC... How can I make it like http://ift.tt/KOWx3o...?


Please notice that I'm not interested in a simple redirection (now the customer is able to access the admin section with http://ift.tt/1oHP0SG, but then he's redirected to http://ift.tt/1AmSvBC..., and it's not what he wants.


Thanks in advance





I'd like to add an fa icon before a link in my 'recent post' side bar


Similar to your 'how to format' side bar----> I've got the code that will pull the icon the question is: where do I insert that, so that with every new post a link appears in the side bar with the icon in front.





publish new post via the front-end and adding to it a custom taxonomy term


I have a form which is adding new posts via the front-end using the function wp_insert_post, my problem is when i'm trying to attach the new post to a custom taxonomy term.


this is my code:



$new_post = array(
'post_title' => $title,
'post_content' => $description,
'post_status' => 'pending',
'post_type' => 'post'
);
$pid = wp_insert_post($new_post);
wp_set_object_terms($pid, array('men2', 'women'), 'group');


my custom taxonomy is hirarrchial (like categories).


the problem is that the wp_set_object_terms doesn't add this to the new post.


Any suggestion?





Switching tabs on the "body" and "sidebar" simultaneously


So, I have this tabs on the body of the page (let's call it "X" and "Y")


And I have a sidebar which also has tabs (X-1) and (Y-1).


Sibebar tab 1 (X-1)'s content is related to the body tab "X" Sidebar tab 2 (y-1)'s content is related to the body tab "Y"


The question that I have is that, is there a way to switch sidebar tabs based on what body content you are viewing?


For example, if you are viewing tab X, then the sidebar shows tab x-1. If you switch to tab y on the body, then the sidebar tab also shows tab y-1 automatically.


Thanks.





vendredi 27 février 2015

Need a event management plugin in which user can show interest that he is willing to go or not


i need a event management plugin in wordpress. i need following modules 1- admin can add events 2- user can show interest to join it.. like facebook event , user can click button on GO/ NOT GO 3- admin can see that users who join that event.





Many users can't access to my wordpress site on mobile by wifi


I have a Wordpress site with a lot of traffic http://goo.gl/CmCEBq


Some people claim that they can't access to my website sometimes with their smartphones by wifi (it happens to me too). The website not load. This issue happen intermitent, because if you try again many times, finally can access to the website.


The website is hosted in a cloud server, with a load balancer.


Can somebody know whats it the problem?





how to load gallery form post via ajax


I would like to create one picture gallery in WordPress and will like to have category and subcategory. For e.g. Galley Sub Gallery Sub Gallery Sub Gallery Sub Gallery Sub Gallery Sub Gallery I want to create each gallery as a post so that In that particular post, I would be able to add a gallery and other content.


For the front and gallery page, I would like to show only sub gallery thumbnail (Say like the Featured Image), When you click on thumbnail, the popup window will appear (any kind of model box). Inside that, it will only show the gallery image with the “next” and “previous” option (Slideshow, next, previous, close button will be great). Maybe some model box script will have this type of option.


To understand what I am trying to say, I have attached an image mockup.


I understand it needs to be called a post gallery via ajex. If I can do all via ajex, then will be nice.


i like to do without plugins but if have any plugins then also fine.


enter image description here





How to display the 'key' as well as 'value' in custom fields


I'm using the following to display custom fields on the front end however, it only shows the 'value' How can I get it to also show the text contained in the 'key'?



<?php
// Display Custom Field Value
echo "<ul>";
echo "<li>".get_post_meta( $post->ID, 'Portrait', true )."</li>";
echo "<li>".get_post_meta( $post->ID, 'January', true )."</li>";
echo "<li>".get_post_meta( $post->ID, '28954', true )."</li>";
echo "</ul>";
?>




Single_cat_title() print the title before text


When I use single_cat_title() get the name of the current category in archive page, it works perfectly but it prints the category title before the text



<h2>
<?php
if (is_category()){
echo 'Category: ' . single_cat_title();
}
?>
</h2>


It says:



UncategorizedCategory:



How do I fix it? Thank you.





Why is converting my database to UTF-8 truncating entries?


I'm running WordPress 4.1.1. My site is hosted at NearlyFreeSpeech.


I've been using my WordPress blog since the days when it encoded information in the latin1 charset. This week, I realized that certain posts on my blog (like these: 1-2-3) weren't displaying Japanese characters--the characters either show up as question marks, or as strings of characters like 日本語.


Clearly, this is an encoding error. Looking at my database in phpMyAdmin, I have many tables and columns in my database with their collation set to latin1_swedish_ci. I sought to fix this by changing the database to UTF-8 in a variety of different ways. They all had the exact same result.


The ways I tried to change the database encoding to UTF-8:



  1. Use the UTF-8 Database Converter plugin

  2. Follow this guide to export the database, replace all instances of "latin1" with "UTF8"

  3. Use a SQL script to convert tables and columns to blob, and then to UTF-8 text (detailed here)

  4. Use a SQL script to recast tables and columns to the datatype they contain, then to blob, and then to UTF-8 text (detailed here)


Expected results:


My site appears the same as it was above, with all themes and settings intact, but now displaying Japanese characters properly.


Actual results for all of the above methods:


Japanese still doesn't display correctly. What's more, database entries end abruptly; for instance, some entries in post_content are missing some or most of their original content. Custom shortcodes, defined by the Shortcoder plugin and stored in the shortcoder_data row in wp_options, are broken because the shortcoder_data entry got abruptly truncated. My theme options, including custom CSS and fonts, appear to have been reset or damaged, most likely due to similar abrupt truncation of database entries.


Luckily, I had the foresight to make all these changes on a duplicate database, so I have a backup with all my data intact.


When I compare the altered data in post_content to the original, I notice something: nearly all of the truncated strings begin with a special character. For instance, a post that once read:



Today it was a pleasant 72° and sunny.



will, in the altered database, read:



Today it was a pleasant 72



I haven't gone through and found all of my truncated posts--I know nothing about mySQL, so I'd have to do that by hand, and that would be an exercise in patience. However, out of a sample of 8 posts that got truncated, 6 of them were clearly truncated at a special character.


What do I need to do to properly convert my database so that Japanese characters display correctly without causing this data loss--or, barring a complete solution, what can I do to properly diagnose what's going on?


Thank you.





Add pagination to table generated by wp_query


I spent hours trying to find a solution to this, but I am not able to figure it out. I have a table that shows user's data and I am trying to add pagination to it.


I have tried by adding "paged" in the array but when I click on the link I get "Page not found".


If I understand correctly the problem is created due to the fact that I have a table generated instead of "calling" posts.


Here's what I have now:



<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'deal_admin' ) ) ): ?>
<div class="dashboard_container section main_block">
<?php
// Purchase history
if ( gb_account_merchant_id() ) {
$deals = null;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'post_type' => gb_get_deal_post_type(),
'post__in' => gb_get_merchants_deal_ids(gb_account_merchant_id()),
'post_status' => 'publish',
'gb_bypass_filter' => TRUE,
'posts_per_page' => 5, // return this many
'paged' => $paged,
'tax_query' => array(
array(
'taxonomy' => gb_get_deal_cat_slug(),
'field' => 'id',
'terms' => array( 81,82,83,84,85,86,87,88,89,90,91,92 ),
'operator' => 'NOT IN',
),
),

);
if ( isset( $_GET['filter'] ) && $_GET['filter'] != '-1' ) {
$args['tax_query'][] = array(
'taxonomy' => gb_get_deal_cat_slug(),
'field' => 'id',
'terms' => array( $_GET['filter'] ),
);
}
$deals = new WP_Query($args);
if ($deals->have_posts()) {
?>

<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'coupon_admin' ) ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php gb_merchant_purchases_report_url( gb_account_merchant_id() ) ?>" class="report_button"><?php gb_e('Purchase History') ?></a> | </span>
<?php if ( function_exists( 'gb_sales_summary_report_url' ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php gb_sales_summary_report_url() ?>" class="report_button"><?php gb_e('Sales Summary Report') ?></a> | </span>
<?php endif ?>
<?php endif ?>

<?php if ( !function_exists('gb_is_user_merchant_role') || gb_is_user_merchant_role( array( 'merchant_admin', 'sales_admin' ) ) ): ?>
<?php if ( function_exists( 'sec_get_users_report_url' ) ): ?>
<span class="specialLink_here" style="font-size:16px;"><a href="<?php echo sec_get_users_report_url() ?>" class="report_button"><?php gb_e('Customer Report') ?></a></span>
<?php endif ?>
<?php endif ?>

<table class="report_table merchant_dashboard" style="margin-top:20px;"><!-- Begin .purchase-table -->

<thead>
<tr>
<th class="contrast th_status" style="padding:10px;"><?php gb_e('Status'); ?> </th>
<th class="purchase-purchase_deal_title-title contrast" style="padding:10px;"><?php gb_e('Deal'); ?></th>
<th class="contrast th_total_sold" style="padding:10px;"><?php gb_e('Total Sold'); ?></th>
<th class="contrast th_published" style="padding:10px;"><?php gb_e('Published'); ?></th>
<th class="contrast th_category" style="padding:10px;">
<form action="" method="get" >
<?php
$selected = ( isset( $_GET['filter'] ) && $_GET['filter'] != '' ) ? $_GET['filter'] : 0 ;
$args = array(
'show_option_none' => gb__('Category Filter'),
'orderby' => 'name',
'hide_empty' => 1,
'exclude' => '81,82,83,84,85,86,87,88,89,90,91,92', // comma separated list of ids.
'echo' => 0,
'name' => 'filter',
'selected' => $selected,
'taxonomy' => gb_get_deal_cat_slug() );
$select = wp_dropdown_categories( $args );
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select);
echo $select;
?>
<noscript><div><input type="submit" value="View" /></div></noscript>
</form>
</th>
<th class="contrast th_reports" style="padding:10px;"><?php gb_e('Reports'); ?></th>
</tr>
</thead>

<tbody>

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

// Build an array of the deal's categories.
$category_array = array();
$cats = gb_get_deal_categories( get_the_ID() );
foreach ( $cats as $cat ) {
$category_array[] = '<a href="'.get_term_link( $cat->slug, gb_get_deal_cat_slug() ).'">'.$cat->name.'</a>';
} ?>
<tr id="published_deal_<?php the_ID() ?>">

<td class="td_status">

<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'sales_admin' ) ) || ( gb_is_user_merchant_role( array( 'sales_admin' ) ) && in_array( gb_get_status(), array( 'open', 'closed' ) ) ) ): ?>
<span class="alt_button<?php if (gb_get_status() == 'closed') echo ' contrast_button' ?>"><a href="<?php the_permalink() ?>"><?php echo gb_get_status() ?></a></span>
<br/>

<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'coupon_admin', 'sales_admin' ) ) ): ?>
<a href="#" class="deal_suspend_button alt_button contrast_button" rel="<?php the_ID() ?>"><?php gb_e('Suspend') ?></a>
<?php endif ?>
<?php endif ?>
</td>

<td class="purchase_deal_title">
<?php the_title() ?>
<br/>
<a href="<?php the_permalink() ?>" target="_blank"><?php gb_e('View Deal') ?></a>
<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'coupon_admin', 'sales_admin' ) ) ): ?>
<a href="<?php gb_deal_edit_url() ?>" target="_blank"><?php gb_e('Edit') ?></a>
<?php endif ?>
</td>

<td class="td_total_sold"><?php gb_number_of_purchases() ?></td>

<td class="td_published"><p><?php printf( gb__('Published: %s'), get_the_date() ) ?></p><p><?php printf( gb__('Modified: %s'), get_the_modified_date() ) ?></p></td>

<td class="td_category"><?php echo implode( ', ', $category_array ) ?></td>

<td class="td_reports">
<?php if ( !function_exists('gb_is_user_merchant_role') || !gb_is_user_merchant_role( array( 'coupon_admin' ) ) ): ?>
<span class="report_button"><?php gb_merchant_purchase_report_link() ?></span>
<?php endif ?>
<span class="report_button"><?php gb_merchant_voucher_report_link() ?></span>
</td>

</tr>
<?php
endwhile; ?>
</tbody>
</table><!-- End .purchase-table -->

<?php
} else {
echo '<p>'.gb__('No sales info.').'</p>';
}
} else {
echo '<p>'.gb__('Restricted to Businesses.').'</p>';
}
?>



<?php if ( $deals->max_num_pages > 1 ) : ?>
<div id="nav-below" class="navigation clearfix">
<div class="nav-previous"><?php next_posts_link( gb__( '<span class="meta-nav">&larr;</span> Older deals' ), $deals->max_num_pages ); ?></div>
<div class="nav-next"><?php previous_posts_link( gb__( 'Newer deals <span class="meta-nav">&rarr;</span>' ), $deals->max_num_pages ); ?></div>
</div><!-- #nav-below -->
<?php endif; ?>
<?php wp_reset_query(); ?>




How is it possible to create a link in a wordpress tab?


I'm hoping someone knows something about turning a wordpress page tab into a link?





News and Featured image


I am trying to list my news items in 3 columns in a vertical design: image, date, title. I'm having some trouble calling the featured image. Is there a specific function that would help me with this? Also add CSS style to list them in 3 columns?


Website Example: http://ift.tt/1AcZvAQ


My Code:



<?php
$posts = get_posts( 'numberposts=2&order=DESC&orderby=post_title&category_name=news' );

foreach ( $posts as $post ) : start_wp();
?>
<?php toolbox_posted_on(); ?>
<h4><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title() ; ?></a></h4>
<?php endforeach; ?>
</div>
<a href="#" class="btn blue">Read All News</a>




wp_nav_menu stored as html in variable?


How to get result of wp_nav_menu() without displaying it, but stored as html in variable.





Overwriting templates in child theme and performance


Is it bad for performance to overwrite custom templates in the child theme?


For example: I have a template called single-music.php in my parent theme. I have put single-music.php in the child theme and have made custom changes there. Is this bad for performance or the incorrect way?





Randomize Arrary With Shortcodes


I am trying to display random users to follow for the user pro plugin. I am displaying the shortcode but not actually doing the shortcode.



<?php $input = Array('[userpro template=list list_per_page=1 list_showbio=1 list_showsocial=0 no_style=true list_users="randomuser1"]','[userpro template=list list_per_page=1 list_showbio=1 list_showsocial=0 no_style=true list_users="randomuser2"]'); ?>


<?php echo $input[array_rand($input)]; ?>


[userpro template=list list_per_page=1 list_showbio=1 list_showsocial=0 no_style=true list_users="randomuser1"] is displaying in the template which is exactly what I need but this does not work unless it is in a widget. I can not use php echo shortcode with this shortcode for whatever reason (probably a plugin issue). The code below shows nothing for me. So how can I get the shortcode that $Input is echoing to be in a widget area?



<?php echo do_shortcode('[userpro template=list list_per_page=1 list_showbio=1 list_showsocial=0 no_style=true list_users="randomuser2"]'); ?>




AJAX POST 500 INTERNAL SERVER ERROR


I am new in WordPress coding and I make one infinity loop for my WordPress blog. Its working great on Local machine (WAMP) but after putting it online at nginx server its showing



POST mysiteurl 500 Internal Server Error


I try to find out the solutions but nothing works for me.. Please someone help me...


Infinite_loop.php



<?php

$infinite_loop= $_POST['pcount']; ?>

<?php require_once("/wp-blog-header.php"); ?>

<div class="x-container-fluid max width main">
<div class="offset cf">
<div class="<?php x_main_content_class(); ?>" role="main">
<?php
global $wpdb;
$args = array( 'posts_per_page' => 10, 'order' => 'DESC', 'offset'=>$infinite_loop );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>


<div>
<div style="width:300px; float:left;">
<?php x_ethos_featured_index(); ?>
</div>
<div style="width:500px; float:right;">
<?php /* print $args['offset']; */ ?>
<?php x_get_view( 'ethos', '_content', 'post-header' ); ?>
<?php x_get_view( 'global', '_content' ); ?>
</div>
</div>
</article>
<?php endforeach;
wp_reset_postdata(); ?>


AJAX IN THEME HEADER



script>
$(document).ready(function() {

var post_page_count = 10;
var height_scroll = 400;
$(window).scroll(function() {

if ($('body').height() <= ($(window).height() + $(window).scrollTop())){
post_page_count = post_page_count+10;

$.ajax({
type: "POST",
async: false,
url: "theme/infinite_loop.php",
data: {pcount:post_page_count},
success:
function(result){


$("#gizinfi").append(result);
}
});
};
});
});
</script>




Change Front Page Word Press 4.1


I simply want change which page is defined as the front page. It is currently my About Me page; I want it to be the page called Home. Thanks.





Programatically added attribute, set to 'show on product page' automatically. Woocommerce


Ive written a script to import products to a new install of Woocommerce.


The products have attributes set up in the admin. This bit of code adds the attributes on import.



update_post_meta($product_id, 'common_name', $product['common_name']);
wp_set_object_terms($product_id, $product['flowering_period'], 'pa_flowering');
wp_set_object_terms($product_id, $product['native_plant'], 'pa_native');


However when I look at the product attribute in admin, the tick box for 'show on product page' is unticked.


Is there a way to set this as ticked using the above function? OR Does it matter if this is ticked or not, if I call the attribute in the template directly using something like get_the_term_list (although most of my attributes have a single term) will it show, or does having this box ticked overide it showing up?





Need ideas for HTTPS multiple domain solution


I'm developing a WordPress site that runs on multiple domains (not WordPress MU). The two domains are served from the same codebase and I have written a plugin that successfully switches themes based on the URL.


This site has a donation form that uses HTTPS (currently using the WordPress HTTPS plugin). However, WordPress HTTPS only has one option for the domain.


I thought that I could maybe get away with replacing this line $ssl_host = rtrim($this->getSetting('ssl_host'), '/') . '/';


...with this $ssl_host = $_SERVER['SERVER_NAME'] . '/';


Unfortunately, it's not that easy. It seems to break the whole site. The site header (and consequently everything else) won't load properly.


Any ideas? Any help here would be much appreciated.





wp_schedule_event every day at specific time


I write Following code to run my function every day at 16:20 ..


But I guess is the problem in code..


not working



if( !wp_next_scheduled( 'import_into_db' ) ) {
wp_schedule_event( time('2015-03-28 16:20:00'), 'daily', 'import_into_db' );

function import_into_db(){

////My code

}
add_action('wp', 'import_into_db');
}




get_option function


I'm currently trying to make my own theme, but i'm not quite sure how the get_option() function works, because how come this..



echo get_option('show_header', 'sultenhest_theme_display_options');
echo get_option('sultenhest_theme_display_options')['show_header'];


..both returns 1 (but Dreamweaver doesnt like the second option). While



echo get_option('twitter', 'sultenhest_theme_social_options');


..simply returns 'sultenhest_theme_social_options', which is incorrect.


An option would be to define the array as such



$social_options = get_option( 'sultenhest_theme_social_options' );


and call it like this



echo $social_options['twitter'];


It returns the correct string, but it only works in the header.php (if the array is defined there) file and not in, e.g. footer.php.





Hacked Site: Blank Login Page


A site I was working on was unfortunately hacked and ever since, I have not been able to access the login page at /wp-admin.


It just shows a blank page. In fear of screwing something up, I'm not sure where to start?


Can someone provide any direction? Here is the site http://ift.tt/1AC4Bvv





Restrict site content to registered users for only 1 day / limited number of views


Is there a plugin out there by which I can allow registered users to only be able to access an eBook a limited number of times / limited number of days?


After which the content should get locked.


Many thanks in advance.





Woocommerce filter cart and category specific quantity


So basically, I'm trying to filter my cart. I would like the message below displayed if products from the "cuvees" category are at the number of 4,5,7,8,9,10,11,13,14,15,16,17,19,21 in the cart.


So far here what I've did but it only works for one value : 7 . Do I need to put an array when I declare the function ?



add_action( 'woocommerce_check_cart_items', 'check_total' );
function check_total() {
// Only run in the Cart or Checkout pages
if( is_cart() || is_checkout() ) {

global $woocommerce, $product;
$i=0;
//$prod_id_array = array();
//loop through all cart products
foreach ( $woocommerce->cart->cart_contents as $product ) :


// Set checking if there's y products in cuvees cart total
$cart_product_total = 4;



// See if any product is from the cuvees category or not
if ( has_term( 'cuvees', 'product_cat', $product['product_id'] ) ) :

$total_quantity += $product['quantity'];
//array_push($prod_id_array, $product['product_id']);
endif;

endforeach;

foreach ( $woocommerce->cart->cart_contents as $product ) :
if ( has_term( 'cuvees', 'product_cat', $product['product_id'] ) ) :
if( $total_quantity == $cart_product_total && $i == 0 ) {
// Display our error message
wc_add_notice( sprintf( '<h5 style="letter-spacing:0.5px;color:white;text-align:center;">/!\&nbsp; Une commande de %s bouteilles n&#39;est pas possible&nbsp;! &nbsp; /!\ </h5><br /> <br /><p style="text-align:center;"> L&#39;envoi n&#39;est possible que pour 1 | 2 | 3 | 6 | 12 | 18 | 24 | 30 | 36 | 42 | 48 | 54 | 60 | 72 | 96 | 120 et plus bouteilles.</p>',
$cart_product_total,
$total_quantity ),
'error' );
}
$i++;
endif;
endforeach;
}
}


Thank you :)





Complex WP_Query order request: DESC by day, but then ASC by time


I've got a site with a couple thousand time-stamped posts in a custom post type. These get displayed by a few taxonomies and a date query in various views (I've got that all working just fine already). The tricky part is ordering them by a unique date format: the client insists that posts should be ordered DESC by day, then ASC by time within each day. As far as I can see in the Codex, order only takes date as a param, not day & time as distinguishable values. Is there any way to accomplish what I'm looking for without substantial re-writes of a half-dozen archive-tax template files?


I'm using the following to sort DESC by date already and would love a solution that fits into this function:



function my_post_sort( $vars ) {
if ( is_tax(array('series', 'speakers', 'topics', 'venues'))) {
$vars['order'] = 'ASC';
}
return $vars;
}
add_filter('query_vars', 'my_post_sort');




Avoid theme updates, just one theme


I stupidly created a ton of websites with custom themes (not child themes, 100% custom) and named my theme folder "custom". Now they are starting to auto-update and get replaced with some theme from the repository that happens to use the same folder name.


I could disable the updates in wp_config, but I don't really like that idea. Isn't there something I can do just in my theme files, to tell WordPress "this is a totally custom theme, not on your repository, don't try to update it"? This info must be around, but I just can't find it. I tried setting a name in my style.css file, but that didn't help, WordPress is still saying "update available" (and will overwrite my files if I click that option).


I usually just don't give my themes a name, my style.css file just starts out with my actual CSS.. and it seems to work fine, until this issue started.


If I rename the folder to something more obscure, that works... but then I'll have to recreate my menus, and not sure what else, because WP thinks I switched themes if I do that.


Maybe some tag I can add to style.css? Something like a "slug" or update URL?





WordPress Pages “allow comments” meta option can't be checked


I'm trying to allow comments on WordPress pages, but when I check the page's "Allow Comments" meta checkbox option ( http://ift.tt/1vktD1V ) and save page, it does NOT save settings, it returns to an UNCHECKED box again! Don't know why?!


My default discussion settings as the following: http://ift.tt/1CPzgm0


PS: it works well on POSTS, but PAGES does not!


Any ideas about how to fix that?


Thanks in advance!





Font options for every post


Is there a plugin where I can choose font options (e.g. font, size, color) for every blog post I write individually?





Advanced Image editing


Is there a plugin, where I get more options when editing an image inside the TinyMCE editor? It should especially have a GUI for adding a border.





Woocommerce: add a transaction fee whichever is higher


i am trying to add a transaction fee to a product, where the rate shall be chosen whichever is higher. below is the example: Product X costs 60$. I want an additional cost to be added as a transaction fee of 3.80$ or 5% of 60$ whichever is higher. So far i am unable to do so.





Custom BuddyPress Registration Form That Updates Specific Field


I'm using a combination of BuddyPress and WPMU Dev's plugin 'Membership Premium.'


What I want to accomplish is:



  • Use a custom BuddyPress registration form (I've followed appropriate template hierarchy to have a 'child form,' which has been tested and works)

  • I want to create a row in the table ua_m_membership_relationships

  • Ideally this row would be populated by hidden fields


My issue is: what is the correct script to populate a row for a specific table for a given user id upon user registration?


Thanks!





How do I sell Genesis Child Themes on ThemeForest?


I've been struggling with all these licences and stuff, I need some serious help. I want to sell Genesis Child Themes on Themeforest, is this even possible? If so I do have some additional questions:


1) Can I simply include Genesis in my .zip file and just be?


2) If not, do I need to inform potential buyers about purchasing another framework? That kinda makes all the sales impossible.


3) And if so, where should I sell these themes instead?


Thanks a lot.





Delete users thats not members of a subsite


I need a code on the multisite network area to auto delete everyone on the network that isnt member of a subsite. It should delete them every 24 hours or directly. Is there anyone having the slightest idea how this can be done?





Get 1st child of category only


At the moment, I'm using get_term_children() to get the children of a category. The problem I'm faced with now is that I only want the first child. I assume I would use get_terms() instead, but I've been battling to implement it with my current code. If someone could point me in the right direction, I'd greatly appreciate it:



// get children of current parent.
$tchildren = get_term_children($term->term_id, $taxonomy);

$children = array();
foreach ($tchildren as $child) {
$cterm = get_term_by( 'id', $child, $taxonomy );
// If include array set, exclude unless in array.
if ( is_array( $include ) && ! in_array( $cterm->slug, $include ) ) continue;
$children[$cterm->name] = $cterm;
}


and the whole section of code is:



function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) {
// Get all terms of the chosen taxonomy
$terms = get_terms($taxonomy, array('orderby' => 'name'));

// our content variable
$list_of_terms = '<select id="location" class="selectboxSingle" name="location">';

if ( ! is_wp_error( $terms ) ) foreach($terms as $term){

// If include array set, exclude unless in array.
if ( is_array( $include ) && ! in_array( $term->slug, $include ) ) continue;

$select = ($current_selected == $term->slug) ? "selected" : ""; // Note: ==

if ($term->parent == 0 ) {

// get children of current parent.
$tchildren = get_term_children($term->term_id, $taxonomy);

$children = array();
foreach ($tchildren as $child) {
$cterm = get_term_by( 'id', $child, $taxonomy );
// If include array set, exclude unless in array.
if ( is_array( $include ) && ! in_array( $cterm->slug, $include ) ) continue;
$children[$cterm->name] = $cterm;
}
ksort($children);

// OPTGROUP FOR PARENTS
if (count($children) > 0 ) {
// $list_of_terms .= '<optgroup label="'. $term->name .'">';
if ($term->count > 0)
$list_of_terms .= '<option class ="group-result" value="'.$term->slug.'" '.$select.'>' . $term->name .' </option>';
} else
$list_of_terms .= '<option value="'.$term->slug.'" '.$select.'>'. $term->name .' </option>';
//$i++;

// now the CHILDREN.
foreach($children as $child) {
$select = ($current_selected == $child->slug) ? "selected" : ""; // Note: child, not cterm
$list_of_terms .= '<option value="'.$child->slug.'" '.$select.'>'. $child->name.' </option>';

} //end foreach

if (count($children) > 0 ) {
$list_of_terms .= "</optgroup>";
}
}
}

$list_of_terms .= '</select>';

return $list_of_terms;
}

add_action( 'wp_ajax_wpse158929_get_terms_for_cpt', 'wpse158929_get_terms_for_cpt' );
add_action( 'wp_ajax_nopriv_wpse158929_get_terms_for_cpt', 'wpse158929_get_terms_for_cpt' );




I'd like to add an fa icon before a link in my 'recent post' side bar


Similar to your 'how to format' side bar----> I've got the code that will pull the icon the question is: where do I insert that, so that with every new post a link appears in the side bar with the icon in front.





Custom Post type archives / categories give 404


I have a client that wants a blog, a press section, and a "More Posts" section for feel good, community service type of posts. I used the standard post type for the blog, and everything works fine. I registered the two other post types with this code which is within a custom_posts(); function that I add with add_action( 'init', 'custom_posts');



register_post_type( 'press',
// let's now add all the options for this post type
array( 'labels' => array(
'name' => __( 'Press', 'bonestheme' ),
'singular_name' => __( 'Press', 'bonestheme' ),
'all_items' => __( 'All Press', 'bonestheme' ),
'add_new' => __( 'Add New', 'bonestheme' ),
'add_new_item' => __( 'Add New Post', 'bonestheme' ),
'edit' => __( 'Edit', 'bonestheme' ),
'edit_item' => __( 'Edit Post', 'bonestheme' ),
'new_item' => __( 'New Post', 'bonestheme' ),
'view_item' => __( 'View Post', 'bonestheme' ),
'search_items' => __( 'Search Posts', 'bonestheme' ),
'not_found' => __( 'Nothing found in the Database.', 'bonestheme' ),
'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ),
'parent_item_colon' => ''
),
'description' => __( 'Press', 'bonestheme' ),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'menu_position' => 8,
'rewrite' => array( 'slug' => 'press-posts' ),
'has_archive' => true,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'thumbnail', 'excerpt', 'revisions', 'sticky', 'custom-fields', 'editor', 'author' )
)
);

register_post_type( 'more_posts',
array( 'labels' => array(
'name' => __( 'More Posts', 'bonestheme' ),
'singular_name' => __( 'Post', 'bonestheme' ),
'all_items' => __( 'All Posts', 'bonestheme' ),
'add_new' => __( 'Add New', 'bonestheme' ),
'add_new_item' => __( 'Add New Post', 'bonestheme' ),
'edit' => __( 'Edit', 'bonestheme' ),
'edit_item' => __( 'Edit Post', 'bonestheme' ),
'new_item' => __( 'New Post', 'bonestheme' ),
'view_item' => __( 'View Post', 'bonestheme' ),
'search_items' => __( 'Search Posts', 'bonestheme' ),
'not_found' => __( 'Nothing found in the Database.', 'bonestheme' ),
'not_found_in_trash' => __( 'Nothing found in Trash', 'bonestheme' ),
'parent_item_colon' => ''
),
'description' => __( 'More Posts', 'bonestheme' ),
'public' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'show_ui' => true,
'query_var' => true,
'menu_position' => 9,
'rewrite' => array( 'slug' => 'more-posts' ),
'has_archive' => true,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'thumbnail', 'excerpt', 'revisions', 'sticky', 'custom-fields', 'editor', 'author' ),
)
);


Press - archive is broken(404) when using custom permalinks (works fine with std perma)


More - archive is broken(404) when using custom permalinks (works fine with std perma)


More - category gives me a page, but returns no posts (there are 2 posts in there)


I am using this plugin to create the archive and category lists on the sidebar, it seems to be functioning correctly. The URLs it gives me are:


/press/2015/02/ - press archives


/more_posts/2015/02/ - more archive


/more-posts-category/giving-back/ - more categories





How do I change the description of the same image which is to be found in multiple instances?


We have the site from http://ift.tt/1543WG7


Feel free to dig the site in order to understand our question below.


Of course, any feedback appreciated :-) but my main question is the following:


We have a photo multiple times on site (in blog, portfolio, and in slide-shows from the menus Body, Mind, Heart).


The description of the photos is taken from 'Description' field from Media Gallery. (As you know the field is filled from photo's EXIF).


Because each time when I attach a photo to a page/post, WordPress copies the photo, we need a plugin/solution/whatever to allow us to change simultaneously the description of all the instances for the eg. myPhoto.jpg.


Now when we want to change/update a caption, we need to go to all instances and manually edit them.


Does someone knows a solution for this problem?





Altering html structure and creating custom menus


I'm fairly new to Wordpress and am trying to do something very specific. I am currently using the awesome html5blank to create my custom theme. I am using the native menus for my nav tabs. I am currently using background-image's to make my nav tabs images instead of text but that is posing problems with what I'm trying to achieve w/ css and making it responsive.


I want to be able to add <img> tags( different image for each <li> ) in my <li>'s via HTML.


As far as I've been able to find and read up, I need to create a custom structure in this found in my function.php file?



function html5blank_nav()
{
wp_nav_menu(
array(
'theme_location' => 'header-menu',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul>%3$s</ul>',
'depth' => 0,
'walker' => ''
)
);
}


Please let me know what else I need to provide to make this question make more sense and help you get me on the right track. Thanks in advance.





How do I get a custom field to work in google maps as a javascript variable [on hold]


I have a custom post type called "events" and I'm storing latitude and longitude in a custom field. I want the events to display in a google map. How do I convert a custom field in to a javascript variable This is what i got so far.



<?php
$timecutoff = date("Y-m-d");
$args = array(
'post_type' => 'events',
'orderby' => 'meta_value',
'meta_key' => 'event_date',
'meta_compare' => '>=',
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$lat = get_field('gp_latitude');
$lon = get_field('gp_longitude');
$eventtime = get_field('event_time');
wp_localize_script( $lat, $lon, $event_time );
?>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['<?php echo json_encode($eventtime);?>';, <?php echo json_encode($lat); ?>;, <?php echo json_encode($lon); ?>;, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});

var infowindow = new google.maps.InfoWindow();

var marker, i;

for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}




How do I get a custom field to work in google maps as a javascript variable [on hold]


I have a custom post type called "events" and I'm storing latitude and longitude in a custom field. I want the events to display in a google map. How do I convert a custom field in to a javascript variable This is what i got so far.



<?php
$timecutoff = date("Y-m-d");
$args = array(
'post_type' => 'events',
'orderby' => 'meta_value',
'meta_key' => 'event_date',
'meta_compare' => '>=',
);
$my_query = new WP_Query($args);
if ($my_query->have_posts()) : while ($my_query->have_posts()) :
$my_query->the_post();
$lat = get_field('gp_latitude');
$lon = get_field('gp_longitude');
$eventtime = get_field('event_time');
wp_localize_script( $lat, $lon, $event_time );
?>
<div id="map" style="width: 500px; height: 400px;"></div>
<script type="text/javascript">
var locations = [
['<?php echo json_encode($eventtime);?>';, <?php echo json_encode($lat); ?>;, <?php echo json_encode($lon); ?>;, 4],
['Coogee Beach', -33.923036, 151.259052, 5],
['Cronulla Beach', -34.028249, 151.157507, 3],
['Manly Beach', -33.80010128657071, 151.28747820854187, 2],
['Maroubra Beach', -33.950198, 151.259302, 1]
];

var map = new google.maps.Map(document.getElementById('map'), {
zoom: 10,
center: new google.maps.LatLng(-33.92, 151.25),
mapTypeId: google.maps.MapTypeId.ROADMAP
});

var infowindow = new google.maps.InfoWindow();

var marker, i;

for (i = 0; i < locations.length; i++) {
marker = new google.maps.Marker({
position: new google.maps.LatLng(locations[i][1], locations[i][2]),
map: map
});

google.maps.event.addListener(marker, 'click', (function(marker, i) {
return function() {
infowindow.setContent(locations[i][0]);
infowindow.open(map, marker);
}
})(marker, i));
}




Local install won't work without internet


I have a local install (using Vangrant and VVV) and it works absolutely fine with internet. But without internet, it hangs on "connecting" indefinitely. I think it's trying to talk to wordpress.org and gravatar.com


Is there a way to disable these connection attempts when there is no internet present?





WPDB Table Does Not Exist


From this code:



global $wpdb;
$sidebar_table = $wpdb->prefix . 'w3care_sidebar_position';
$checkad = $wpdb->get_results( $wpdb->prepare( "SELECT ad_id, sidebar_position, ad_type FROM `%s` WHERE page_id = '11646' AND page_type='page'",$sidebar_table ));


I'm getting the following error:



WordPress database error Table 'wp_rainnews.'wp_w3care_sidebar_position'' doesn't exist for query SELECT ad_id, sidebar_position, ad_type FROM `'wp_w3care_sidebar_position'` WHERE page_id = '11646' AND page_type='page' /* From [siteurl/] in [/urltopluginindex/index.php:855] */ made by .....


But I don't know how this is possible. If I echo $sidebar_table it returns wp_w3care_sidebar_position, so where is this wp_rainnews coming from? And what's with the quotes around it? If anyone can offer any help I would be very appreciative. :)





How to Make Google Maps appear correctly in Tabs


This is a widely acknowledged issue among the WordPress community, From all of the answers, it seems no one has provided an answer for implemting in Easy Responsive Tabs.





Why is my sub-category template showing the wrong posts


I've got a problem with a custom category template. Used on sub-categories for a particular parent.


For some odd reason it's not showing posts store within it, but instead from a another sub-category.


I don't quite understand it, as the loop is the same as is used on my category.php page. The difference if the code before hand.


Here is the code:



<?php get_header(); ?>


<?php global $post; ?>
<?php
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );
?>
<div class="parallax" id="parallax1" style="background: url(<?php echo $src[0]; ?> ) !important; background-position: 50% 50% !important; background-repeat: no-repeat !important; background-size: cover; background-attachment: fixed !important;">
<div class="parallax-content">
<h1 class="page-title"><?php
printf( __( '%s', 'adventure' ), '<span>' . single_cat_title( '', false ) . '</span>' );
?></h1>
<?php
// Display optional category description
$category_description = category_description();
if ( ! empty( $category_description ) )
echo '<div class="archive-meta">' . $category_description . '</div>';
get_template_part( 'loop', 'category' );
?>
</div>
</div>

<div id="page-wrapper">

<div id="content-container">
<div class="page-content">
<!-- START THE LOOP -->
<?php $posts=query_posts($query_string . '&order=asc');
while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

<?php echo catch_video() ?>

<!-- Get featured image -->
<?php if ( has_post_thumbnail() ) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php the_post_thumbnail(); ?>
</a>
<?php endif; ?>
<div class="post-content">

<div class="post-info top">
<span class="post-date"><?php the_date('j F, Y'); ?></span>
<span class="no-caps post-autor">by <?php the_author(); ?></span>
</div>
<h1 class="post-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<?php print_excerpt(500); ?>
<a class="read-more-btn" href="<?php the_permalink(); ?>"><?php _e( 'Read More &rarr;'); ?></a>
<div class="post-info bottom">
<span class="post-date">In: <?php the_category(', ') ?>&nbsp; <?php comments_number( 'no comments', 'one comment', '% comments' ); ?> </a>
</span>
</div>
<div class="clear"></div>

</div><!-- post content -->
</article>
<?php endwhile; ?>
<div id="blog-pagination">
<div class="alignleft"><?php previous_posts_link('«&nbsp; Previous'); ?></div>
<div class="alignright"><?php next_posts_link('Next &nbsp; »'); ?></div>
</div>
</div><!-- page content -->


</div><!-- content container -->
</div><!-- page wrapper -->

<?php get_footer(); ?>


Can anyone help me understand what is happening here. I thought it might be because there is some kind of pseudo loop used to get the category titles and description, but I tired resetting the query 'wp_reset_query();' without any success.


Thanks





Using Contact Forms to Send Private Information


I am working on a site for a Doctors Office who wants to use a contact form to send information about their patients to other offices....I was going to use contact form 7 but I'm wondering if there is a security issue with sending private information. Do you have any suggestions on the best forms to use for sending personal information securely? Maybe they should get an SSL? Any suggestions are appreciated!





How to change strings in the theme/core?


When I use Joomla I can change a core string using the language files. So where it would say "Cart" you would go into the language file and change it to what you want it to say.


I want to be able to do this for one of our client's websites which uses WordPress. Is this possible? I am using the wpex-adapt theme.


The exact bit I want to change is on the Portfolio page on the individual item page where it says "newer" and "older" which I want to change to "previous" and "next".


Any help will be greatly appreciated, thanks.





How to place an array in a class [on hold]


I cannot figure out how to pull in the categories for the products from the backend as an array to load into a class. I can code a loop to pull in the data on a normal page, but cant figure out how to do it in a class.


You can see that I am trying to populate the $productcats with all the categories of the products. I can code it in manually, I just cannot seem to get it to work dynamically pulling in from the database.



if ( ! class_exists( 'WC_my_sweet_plugin' ) ) {

class WC_my_sweet_plugin {
public function __construct() {
add_action( 'woocommerce_before_shop_loop_item_title', array( $this, 'woocommerce_show_product_loop_my_sweet_plugin' ), 30 );

//Manually added array - how to pull this data in is my problem.
$productcats = array(
'clothing' => __( 'Clothing', 'woocommerce-my-sweet-plugin' ),
'hoodies' => __( 'Hoodies', 'woocommerce-my-sweet-plugin' ),
't-shirts' => __( 'T-shirts', 'woocommerce-my-sweet-plugin' ),
'music' => __( 'Music', 'woocommerce-my-sweet-plugin' ),
'albums' => __( 'Albums', 'woocommerce-my-sweet-plugin' ),
'singles' => __( 'Singles', 'woocommerce-my-sweet-plugin' ),
'posters' => __( 'Posters', 'woocommerce-my-sweet-plugin' ),
);

// Init settings
$this->settings = array(
array(
'name' => __( 'My Sweet Plugin', 'woocommerce-my-sweet-plugin' ),
'type' => 'title',
'id' => 'wc_my_sweet_plugin_options'
),
array(
'name' => __( 'Product Category', 'woocommerce-my-sweet-plugin' ),
'desc' => '<br/>' . __( 'Select the product categories you want the Free Shipping badge to appear on.', 'woocommerce-my-sweet-plugin' ),
'id' => 'wc_my_sweet_plugin_category',
'css' => 'min-width:400px;',
'desc_tip' => __( "A cool tool tip that is displayed on hover.", 'woocommerce-my-sweet-plugin' ),
'class' => 'wc-enhanced-select',
'type' => 'multiselect',
'options' => $productcats
),
array( 'type' => 'sectionend', 'id' => 'wc_my_sweet_plugin_options' ),
);


// Default options
add_option( 'wc_my_sweet_plugin_category', '' );


// Admin
add_action( 'woocommerce_settings_image_options_after', array( $this, 'admin_settings' ), 20 );
add_action( 'woocommerce_update_options_catalog', array( $this, 'save_admin_settings' ) );
add_action( 'woocommerce_update_options_products', array( $this, 'save_admin_settings' ) );
}


I have tried adding this after the __construct() just to see if I can pull in the categories but I only get undefined variable & get property of non-object errors:



$category_ids = (array) get_post_meta( $post->ID, 'product_categories', true );
$categories = get_terms( 'product_cat', 'orderby=name&hide_empty=0' );

if ( $categories ) foreach ( $categories as $cat ) {
echo '<pre>' . esc_attr( $cat->term_id ) . '"' . selected( in_array( $cat->term_id, $category_ids ), true, false ) . '>' . esc_html( $cat->name ) . '</pre>';
}




Need help with get_posts pagination


I've been working on a wordpress site, and I'm trying to build a page where visitors can see all of the images that have been uploaded to the wordpress media gallery, regardless of whether or not said images are attached to any particular posts. The images from the query are showing up, but the pagination links are not. I can view the paginated pages by including page/2/ or page/3/ at the end of my URL, but the pagination links to bring viewers to those pages aren't showing up at all.


The gallery is located at http://ift.tt/1DhCwXw The images on http://ift.tt/1vG6KWJ and http://ift.tt/1DhCzmk are not the same images as the images on http://ift.tt/1DhCwXw so I assume pagination is possible here.


The code for the gallery template is as follows:



<?php
/*
Template Name: Gallery
*/
get_header(); ?>
<div class="main" role="main">
<div class="standard-section">
<div class="gallery">
<h1 class="big-centered-h1">Photo Category #1</h1>
<div class="gallery-images">
<?php
$gallery_page_args = array(
'post_type' => 'attachment',
'posts_per_page' => 8,
'paged' => $paged,
'post_mime_type' =>'image'
);
$the_gallery_page_attachments = get_posts($gallery_page_args);
if ($the_gallery_page_attachments) {
foreach ($the_gallery_page_attachments as $attachment) {
echo '<a class="img-lightbox-wrapper" href="';
echo wp_get_attachment_url($attachment->ID);
echo '">';
echo '<img class="gallery-image" src="';
echo wp_get_attachment_thumb_url($attachment->ID);
echo '">';
echo '</a>';
}
}
?>
<?php
echo '<div class="clearfix"></div>';
echo '<div class="left-pagination">';
previous_posts_link('Go back');
echo '</div>';
echo '<div class="right-pagination">';
next_posts_link('See More', $the_gallery_page_attachments->max_num_pages);
echo '</div>';
echo '<div class="clearfix"></div>';
?>
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<?php get_footer(); ?>


Any help would be greatly appreciated!