Jump to content

pahunrepublic

Members
  • Posts

    75
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

pahunrepublic's Achievements

Member

Member (2/5)

0

Reputation

  1. Ok I updated WP and after checked like several hours to see if any core files got generated. There is none for now so far. I'll see it tomorrow. Anyway thanks for the threads.
  2. Hi Everyone. I hired a guy to make some wordpress modifications for me in a theme. Mainly php and mysql coding. Now I am looking inside the Wordpress folder where all the files are. There are some kind of core files appear (i.e. core.4459, core123). I don't know what those are. I thought it has to do with some webhosting backupfiles or something so I asked support and they said this: I'm lost. I am basic php coder but this one is new for me. What can be done in this situation? The guy I hired really messed up right? These files regenerate every day a whole bunch of them. I have the suspicions it also has something to do with this case I'm having lately when I view my site it gives me this" it gives me "Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request...." It does the same thing with some other posts. Other thing - I don't know if it has something to do with these core files but I get like 2 account suspensions a week from my webhosting company because they say:
  3. The solution was that we needed a global variable inside the function that represents a post from the Wordpress database: global $post; global $wpdb; Finally the function looks like this <?php add_action('show_etiqueta','et_get_post_user_etiqueta', 10, 0); function et_get_post_user_etiqueta(){ global $post; global $wpdb; $post_id = $post->ID; $result = $wpdb->get_results($wpdb->prepare("SELECT cm.meta_value, count(*) AS countof FROM $wpdb->commentmeta cm, $wpdb->comments c WHERE cm.comment_id=c.comment_ID AND c.comment_post_id = %d AND cm.meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 1", $post_id)); echo "<table>"; foreach($result as $key => $value) //foreach ( $result as $value) { echo " <tr> <td>" . $value->meta_value . "</td> <td>" . $value->countof . "</td> </tr> "; } echo "</table>"; $result = $value->meta_value; if ( !get_post_meta($post_id,'_et_inreview_comments_etiqueta',true) ) update_post_meta($post_id,'_et_inreview_comments_etiqueta',$result); return $result; }?> Thank you erm410 for your help
  4. Let me share the files that modify everything. They're located in a theme folder. [attachment deleted by admin]
  5. it gives me this: The post ID is: and the sql query is: SELECT cm.meta_value, count(*) AS countof FROM wp_commentmeta cm, wp_comments c WHERE cm.comment_id=c.comment_ID AND c.comment_post_id=0 AND cm.meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5 The query result is: Array ( )
  6. I tried with this solution but no output. It doesn't display the value, than I tested in phpmyadmin to see if the SQL query gives a result: SELECT cm.meta_value, count(*) AS countof FROM wp_commentmeta cm, wp_comments c WHERE cm.comment_id=c.comment_ID AND c.comment_post_id=45 AND cm.meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5 the query is good but only if I set the comment_post_ID: c.comment_post_id=45 as you can see. Any idea how to make it display for each single post the corresponding value?
  7. still :-\ . I don't know what do do. This is the last thing I can come up with: <?php function et_get_etiqueta_value($post_id) { global $wpdb; return $wpdb->get_results($wpdb->prepare("SELECT meta_value FROM $wpdb->commentmeta WHERE meta_key='et_comment_etiqueta'ORDER BY comment_ID", $post_id)); } add_action('show_etiqueta','et_get_post_user_etiqueta'); function et_get_post_user_etiqueta( $post_id ){ $approved_comments = et_get_approved_comments( $post_id ); if ( empty($approved_comments) ) return 0; $user_etiqueta = 0; $approved_comments_number = count($approved_comments); foreach ( $approved_comments as $comment ) { $comment_etiqueta = get_comment_meta($comment->comment_ID,'et_comment_etiqueta',true) ? get_comment_meta($comment->comment_ID,'et_comment_precio',true) : 0; if ( $comment_etiqueta == 0 ) $approved_comments_number--; $user_etiqueta += $comment_etiqueta; } //this where it gets the top 1 word $result = et_get_etiqueta_value($post_id); if(is_array($result)){ $unique_count = array_count_values($result ); arsort($unique_count); while (list ($word, $value) = each ($unique_count)) { $counted_array[] = $word; // $value } return $counted_array[0]; } else { if ( !get_post_meta($post_id,'_et_inreview_comments_precio',true) ) update_post_meta($post_id,'_et_inreview_comments_precio',$result); } return $result; }?>
  8. I want to display next to the post content values that are submitted through a custom comment field. The function that I'm trying to make is creates a top list where the top 5 are the most submitted words appear. I want to make that post specific. For each individual single post must have a top 5 words list. Now it makes a top list from all the submitted words at all the posts. Here is what I did so far: <?php add_action('show_etiqueta','et_get_post_user_etiqueta'); function et_get_post_user_etiqueta( $post_id ){ $approved_comments = et_get_approved_comments( $post_id ); global $wpdb; $result = $wpdb->get_results($wpdb->prepare("SELECT meta_value, count(*) AS countof FROM $wpdb->commentmeta WHERE meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 1", $post_id)); echo "<table>"; //foreach($result as $key => $value) foreach ( $result as $post_id => $value) { echo " <tr> <td>" . $value->meta_value . "</td> <td>" . $value->countof . "</td> </tr> "; } echo "</table>"; update_post_meta($post_id,'_et_inreview_comments_etiqueta',$result); return $result; }?> 'etiqueta' means label in English The tables that are affected are: -wp_commentmeta: meta_id; comment_id; meta_key; meta_value columns -wp_postmeta: meta_id; post_id; meta_key; meta_value Can anyone help me with this?
  9. I tried to output: add_action('show_etiqueta','et_get_post_user_etiqueta'); function et_get_post_user_etiqueta( $post_id ){ global $wpdb; $result = $wpdb->get_results($wpdb->prepare("SELECT meta_value, count(*) AS countof FROM $wpdb->commentmeta WHERE meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5", $post_id)); print_r($result); return $result; } in comment.php inserted: <?php do_action( 'show_etiqueta' ); ?> and it gives me this: Array( [0] => stdClass Object ( [meta_value] => test [countof] => 3 ) [1] => stdClass Object ( [meta_value] => inprediscible [countof] => 1 ) [2] => stdClass Object ( [meta_value] => interesante [countof] => 1 ) [3] => stdClass Object ( [meta_value] => aqui va tu etiqueta [countof] => 1 ) [4] => stdClass Object ( [meta_value] => hurtest [countof] => 1 ) ) As you can see I changed the sql query: SELECT meta_value, count(*) AS countof FROM $wpdb->commentmeta WHERE meta_key='et_comment_etiqueta' GROUP BY meta_value ORDER BY countof DESC LIMIT 5 and I tested in phpmyadmin to see what result it gives me and it gave me the right result:
  10. Ok there is a good news and a bad news. The label (etiqueta) appears now in the comment box. The problem was that it passed it as an integer and it is a string (a word) actually. Only the last and the most important problem to solve left is to display the most frequently submitted label (etiqueta) next to the post. I created a function that retrieves all the labels and counts them. <?php function et_get_post_user_etiqueta( $post_id ){ global $wpdb; $result = $wpdb->get_results($wpdb->prepare("SELECT meta_value, count(*) FROM $wpdb->wp_commentmeta WHERE meta_key ='et_comment_etiqueta' GROUP BY meta_value DESC LIMIT 1", $post_id)); if ( !get_post_meta($post_id,'_et_inreview_comments_etiqueta',true) ) update_post_meta($post_id,'_et_inreview_comments_etiqueta',$result); return $result; }?> The only problem it outputs: 'Array' so I'm still struggling. [attachment deleted by admin]
  11. Well I'm trying here very hard. :'( I'm feeling that I'm so close to the solution but as always happens I can't figure out what's wrong. Let me detail everything here The custom comment form field where user submits label (etiqueta means label in Spanish) : comments.php ...<p><?php do_action( 'et_comment_form_etiqueta' ); ?></p>... Calls function hook in additional_functions.php and rest of the functions that concerns this particular custom comment field (label=etiqueta) ... <?php } } add_action('et_comment_form_etiqueta','et_choose_etiqueta'); function et_choose_etiqueta(){ #adds 'Ponle Precio' to the comment form ( frontend ) if ( !is_page() ) { <p>Tu etiqueta:<input type="text" name="et_etiqueta" id="precio" value="aqui va tu etiqueta" size="22" tabindex="3" /></p> } } add_action('comment_post','et_add_etiqueta_commentmeta', 10, 2); function et_add_etiqueta_commentmeta( $comment_id, $comment_approved ){ #when user adds a comment, check if it's approved $comment_etiqueta = ( isset($_POST['et_etiqueta']) ) ? $_POST['et_etiqueta'] : 0; add_comment_meta($comment_id,'et_comment_etiqueta',$comment_etiqueta); if ( $comment_approved == 1 ) { $comment_info = get_comment($comment_id); et_update_post_user_etiqueta( $comment_info->comment_post_ID ); } } add_action('comment_post','et_add_etiqueta_commentmeta', 10, 2); function et_add_etiqueta_commentmeta( $comment_id, $comment_approved ){ #when user adds a comment, check if it's approved $comment_etiqueta = ( isset($_POST['et_etiqueta']) ) ? $_POST['et_etiqueta'] : 0; add_comment_meta($comment_id,'et_comment_etiqueta',$comment_etiqueta); if ( $comment_approved == 1 ) { $comment_info = get_comment($comment_id); et_update_post_user_etiqueta( $comment_info->comment_post_ID ); } } add_action('et-comment-meta-etiqueta','et_show_comment_etiqueta'); function et_show_comment_etiqueta( $comment_id ){ #displays user comment etiqueta on single post page ( frontend ) $user_comment_etiqueta = get_comment_meta($comment_id,'et_comment_etiqueta',true) ? get_comment_meta($comment_id,'et_comment_etiqueta',true) : 0; if ( $user_comment_etiqueta <> 0 ) { ?> <?php echo $user_comment_etiqueta; ?> <?php } } function et_get_top_etiqueta($top_etiqueta) { global $wpdb; return $wpdb->get_results($wpdb->prepare("SELECT meta_value, count(*) as countof FROM $wpdb->commentmeta WHERE meta_key = 'et_comment_etiqueta' ORDER BY countof DESC LIMIT 1", $post_id)); } function et_get_post_user_etiqueta( $post_id ){ #gets under process user (comments) added etiqueta for the post #this function adds the most popular etiqueta (label) to the post. (it needs to be calculated) $approved_comments = et_get_approved_comments( $post_id ); if ( empty($approved_comments) ) return 0; $user_etiqueta = 0; $approved_comments_number = count($approved_comments); foreach ( $approved_comments as $comment ) { $comment_etiqueta = get_comment_meta($comment->comment_ID,'et_comment_etiqueta',true) ? get_comment_meta($comment->comment_ID,'et_comment_etiqueta',true) : 0; if ( $comment_etiqueta == 0 ) $approved_comments_number--; $user_etiqueta += $comment_etiqueta; } //we need a variable where the most times submitted label is stored. $result = et_get_top_etiqueta( $top_etiqueta ); # save user rating to the post meta if ( !get_post_meta($post_id,'_et_inreview_comments_etiqueta',true) ) update_post_meta($post_id,'_et_inreview_comments_etiqueta',$result); return $result; } function et_update_post_user_etiqueta( $post_id ){ #update user added etiqueta for the post $new_comments_etiqueta = et_get_post_user_etiqueta( $post_id ); if ( get_post_meta($post_id,'_et_inreview_comments_etiqueta',true) <> $new_comments_etiqueta ) update_post_meta($post_id,'_et_inreview_comments_etiqueta',$new_comments_etiqueta); } function et_get_approved_comments($post_id) { global $wpdb; return $wpdb->get_results($wpdb->prepare("SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1' ORDER BY comment_date", $post_id)); } ?>... And this is the where the label (etiqueta) is supposed to appear in the comment box next to each comment submitted by users but IT DOESN'T The label submitted by each user gets inserted in the database correctly but it just doesn't get displayed next to the comment in the comment box <b>Etiqueta:</b> <?php do_action('et-comment-meta-etiqueta', get_comment_ID());?> In order to display the most frequently submitted label (etiqueta) next to the post I used this function which can also be found in additional_functions.php above IT DOESNT WORK EITHER!! <?php add_action('et-comment-meta-etiqueta','et_show_comment_etiqueta'); function et_show_comment_etiqueta( $comment_id ){ #displays user comment etiqueta on single post page ( frontend ) $user_comment_etiqueta = get_comment_meta($comment_id,'et_comment_etiqueta',true) ? get_comment_meta($comment_id,'et_comment_etiqueta',true) : 0; if ( $user_comment_etiqueta <> 0 ) { echo $user_comment_etiqueta; } } function et_get_top_etiqueta($top_etiqueta) { global $wpdb; return $wpdb->get_results($wpdb->prepare("SELECT meta_value, count(*) as countof FROM $wpdb->commentmeta WHERE meta_key = 'et_comment_etiqueta' ORDER BY countof DESC LIMIT 1", $post_id)); }?> This are the tables that uses the theme: -wp_commentmeta which has 4 columns: meta_id; comment_id; meta_key; meta_value -wp_postmeta which has 4 columns: meta_id; post_id; meta_key; meta_value I also attached the theme files that the comment form uses. [attachment deleted by admin]
  12. Wow I never thought that someone would answer my thread, and with a solution. THANK YOU QuickOldCar. I tried it out and it works but the big task begins now is to incorporate it in Wordpress. I tried to create a simple script which does the same thing: http://www.phpfreaks.com/forums/index.php?topic=347890.msg1641823#msg1641823 and with help it turns out that it can also be solved with MySQL query but I guess your solution is going to work better with a wordpress theme because it doesn't give the result using SQL query.
  13. So It would be interpreted like this?: "select and count all the rows from words column in labels table ..." SELECT words, count(*) as countof FROM labels GROUP BY words order by countof DESC
  14. SELECT words, count(*) as countof FROM labels GROUP BY words order by countof DESC Yes this is what I wanted. Thank you gizmola. I never thought this should be resolved with MySQL query. I have some questions. I try to interpret this SQL query but I couldn't find this 'countof'. What does it do? Which part of the query counts the rows in the table? Any tutorial on this topic?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.