Forum Replies Created

Viewing 15 replies - 1 through 15 (of 74 total)
  • Thread Starter Tom Combs

    (@tcwebguru)

    bcworkz…
    Very sorry for the delay in getting back.
    Thanks for your help on this issue.

    I was trying things similar to your suggestion, but i wasn’t adding the .value. Once I did that, everything worked perfectly.

    Thanks again!!

    Thread Starter Tom Combs

    (@tcwebguru)

    bcworkz,
    Thanks for the direction and explanation.
    So I’ve spent the last 12hrs learning about how ajax works with wordpress and I’ve made some progress, but I’m still stuck trying to figure out what to do next.

    I checked the console log and I can see that the slug of my custom taxonomy is being passed to the javascript file. However, I’m not sure how I can pass that slug back to php as a variable so that I can use it to run a query to generate my output.

    This is what my code looks like that generates the dropdown

    $categories = get_terms(array('taxonomy' => 'sports_roster_category'));
      		  $select = "<select name='cat' id='cat' class='postform'>n";
      		  $select.= "<option value='-1'>Select category</option>n";
    
    		  foreach($categories as $category){
    			if($category->count > 0){
    				$select.= "<option value='".$category->slug."'>".$category->name."</option>";
    			}
    		  }
    
    		  $select.= "</select>";
    
    		  echo $select; { ?>
              <img src="<?php echo admin_url('/images/wpspin_light.gif'); ?>" id="roster_loading" class="waiting" style="display:none;" />
    
         </div>
         <div id="roster_results"></div>
    		<?php	}

    This is my javascript code. By viewing the console log, I can see that when I select an option in the dropdown, that the selection is being passed to javascript

    jQuery(document).ready(function($) {
    	var sel = document.getElementById('cat');
    	var slug = sel;
    
    	$('#cat').change(function(){
    		 $('#roster_loading').show();
    		 data = {
    			 action: 'roster_get_results',
    			 roster_nonce: roster_vars.roster_nonce,
    
    		};
    		 $.post(ajaxurl, data, function(response) {
    		 	$('#roster_results').html(response);
    			$('#roster_loading').hide();
    	});
    		 console.log( slug.value );
    		 return false;
    	 });
    
    });

    What I can’t figure out how to do, is pass the “var slug” back to php as variable so that I can use it in my query to display the results based upon which dropdown category is selected.

    Works for me. When I click the link it opens my email client.

    @jbeckett729 – Everyone here is correct, you really don’t want a lot of custom pages if you can avoid it. However, I do understand needing/wanting control over certain post_types or custom pages.

    best thing to do is to check out WordPress Page Templates

    I think that’s probably the solution you are looking for.

    Error establishing a database connection – Indicates that you most likely have the wrong information in your wp-config.php file.
    Either your Database Name, Database User name, Database Password, or Database Host Name.
    Go back and make sure the names match the ones you used when you created your database and that will most likely fix your issue.

    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'My_Database_Name');
    
    /** MySQL database username */
    define('DB_USER', 'My_Username');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'My_password');
    
    /** MySQL hostname - This value may be "localhost" or possibly the IP address of your webserver or the name of your webserver.  Check with your webhost if you are unsure */
    define('DB_HOST', 'My_hostname');

    Hope this helps

    Thread Starter Tom Combs

    (@tcwebguru)

    Excellent! Glad we were able to work together on this!

    Thread Starter Tom Combs

    (@tcwebguru)

    Thanks so much for jumping in to help out. i’m like you, I hate when I can’t figure something out.

    I also posted at phpfreaks.com and I got some help there too.
    Here’s what I ended up with, it’s working perfectly.

    <?php
    $args  = array(
      'fields' => 'all',
      'role' => 'Subscriber',
      'meta_query' => array(
      					array(
    						'key'=>'instrument'
    						))
      );
    $members = get_users($args);
    
    //custom function for comparing the data we want to sort by
    function cmp($a, $b){
      if ($a->instrument == $b->instrument) {
        return 0;
      }
      return ($a->instrument > $b->instrument) ? 1 : -1;
    } 
    
    usort($members, 'cmp'); 
    
    $directory = array();
    foreach ($members as $member ) { // get all the user's data
    $member_info = get_userdata($member->ID);
    foreach ($member_info->instrument as $inst) {
    $directory[$inst][] = array (
    'lastname' => $member_info->last_name,
    'firstname' => $member_info->first_name,
    'address' => $member_info->address_1,
    'city' => $member_info->city,
    'state' => $member_info->state,
    'zip' => $member_info->zip,
    'phone' => $member_info->phone,
    'email' => $member_info->email
    );
    }}
    ksort($directory);  // sort by instrument
    foreach ($directory as $instrument => $players) {
    echo '<h2>' .$instrument. '</h2>';
    sort($players);  // sort players by lastname
    foreach ($players as $player) {
    		echo '<div id="membox">';
    		echo $player['firstname']. ' ' .$player['lastname'].'';
    		echo $player['address'].'';
    		echo $player['city'].', '.$player['state'].', '.$player['zip'].'';
    		echo $player['phone'].'';
    		echo '<a href="mailto:'.$player['email'].'">'.$player['email'].'</a>';
    		echo '<b>'.$instrument.'</b>, ';
    		echo '</div>';
     }}
    ?>

    [moderated: please ensure that your code is enclosed in backticks (`) or use the code button.]

    Thread Starter Tom Combs

    (@tcwebguru)

    We’re almost there. You may notice, that even though the categories look right, the same member appears in each one.

    here is the code for where I am now:

    <?php
    $args = array(
    ‘fields’ => ‘all’,
    ‘role’ => ‘Subscriber’,
    ‘meta_query’ => array(
    array(
    ‘key’=>’instrument’
    ))
    );
    $members = get_users($args);

    //custom function for comparing the data we want to sort by
    function cmp($a, $b){
    if ($a->instrument == $b->instrument) {
    return 0;
    }
    return ($a->instrument > $b->instrument) ? 1 : -1;
    }

    usort($members, ‘cmp’);

    $directory = array();
    foreach ($members as $member ) { // get all the user’s data
    $member_info = get_userdata($member->ID);
    foreach ($member_info->instrument as $inst) {
    $directory[$inst][] = array (
    ‘lastname’ => $member_info->last_name,
    ‘firstname’ => $member_info->first_name,
    ‘address’ => $member_info->address_1,
    ‘city’ => $member_info->city,
    ‘state’ => $member_info->state,
    ‘zip’ => $member_info->zip,
    ‘phone’ => $member_info->phone,
    ’email’ => $member_info->email
    );
    }}
    ksort($directory); // sort by instrument
    foreach ($directory as $instrument => $players) {
    echo ‘<h1>’ .$instrument. ‘</h1>’;
    sort($players); // sort players by lastname
    foreach ($players as $player) { // output player details here
    echo ‘<div id=”membox”>’;
    echo $member_info->first_name. ‘ ‘ .$member_info->last_name.’
    ‘;
    echo $member_info->address_1.’
    ‘;
    echo $member_info->city.’, ‘.$member_info->state.’, ‘.$member_info->zip.’
    ‘;
    echo $member_info->phone.’
    ‘;
    echo ‘email.'”>’.$member_info->email.’
    ‘;
    foreach ($member_info->instrument as $inst) {
    echo ‘<b>’.$inst.'</b>, ‘; }
    echo ‘</div>’;
    }}
    ?>

    Thread Starter Tom Combs

    (@tcwebguru)

    Ok…almost there. Now I have only the member of the instrument showing up. But now I need to combine the instruments, instead of each showing up individually


    <?php

    $args = array(
    ‘fields’ => ‘all_with_meta’,
    ‘role’ => ‘Subscriber’,
    ‘meta_query’ => array(
    array(
    ‘key’=>’instrument’
    ))
    );

    $user_query = new WP_User_Query ($args);

    // User Loop
    if ( !empty( $user_query->results ) ) {

    foreach ( $user_query->results as $category )
    foreach ( $category->instrument as $cat ) {
    echo ‘<h2>’ .$cat . ‘</h2>’;

    foreach ( $user_query->results as $user ) {
    if ( $category->instrument == $user->instrument ) {
    echo ‘<div id=”membox”>’;
    echo $user->first_name. ‘ ‘ .$user->last_name.’
    ‘;
    echo $user->address_1.’
    ‘;
    echo $user->city.’, ‘.$user->state.’, ‘.$user->zip.’
    ‘;
    echo $user->phone.’
    ‘;
    echo ‘email.'”>’.$user->email.’
    ‘;
    foreach ($user->instrument as $inst) {
    echo ‘<b>’.$inst.'</b>, ‘; }
    echo ‘</div>’;
    }}
    }} else {
    echo ‘No users found.’;
    }

    ?>

    Thread Starter Tom Combs

    (@tcwebguru)

    Yeah, it’s almost there.
    not sure if I’m missing an if/else statement, but it’s close.

    Thread Starter Tom Combs

    (@tcwebguru)

    Here’s what I have now. I’m almost where I want to be, however, something is obviously still wrong.

    ‘<?php

    $args = array(
    ‘fields’ => ‘all_with_meta’,
    ‘role’ => ‘Subscriber’,
    ‘meta_query’ => array(
    array(
    ‘key’=>’instrument’
    ))
    );

    $user_query = new WP_User_Query ($args);

    // User Loop
    if ( !empty( $user_query->results ) ) {

    foreach ( $user_query->results as $category ) {
    foreach ( $category->instrument as $cat ) {
    echo ‘<h2>’ .$cat . ‘</h2>’;

    echo ‘<div id=”membox”>’;
    echo $category->first_name. ‘ ‘ .$category->last_name.’
    ‘;
    echo $category->address_1.’
    ‘;
    echo $category->city.’, ‘.$category->state.’, ‘.$category->zip.’
    ‘;
    echo $category->phone.’
    ‘;
    echo ‘email.'”>’.$category->email.’
    ‘;
    foreach ($category->instrument as $inst) {
    echo ‘<b>’.$inst.'</b>, ‘; }
    echo ‘</div>’;
    }
    }} else {
    echo ‘No users found.’;
    }

    ?>’

    I’m getting them sorted with instruments, but it’s only listing 1 member per instrument, and it’s listing the same instrument multiple times.
    Check the link and you can see what I mean: https://afm1.org/wp/?page_id=677

    Thread Starter Tom Combs

    (@tcwebguru)

    deepbevel, thanks for helping.
    I’m trying your code now, will update in a few.

    Some developers put encrypted code in their themes.

    The encrypted code is to prohibit users from downloading the free theme, modifying it, then removing credits of the original author of the theme so that the user can claim it as their own.

    If you try to remove the encryption (Base64), your theme will break.

    I don’t agree with the practice of using encryption, but that’s another discussion.
    There are ways to remove it, but you’ll have to search the internet for those methods.

    Something else you may want to try, is go into Appearance > Themes > and make sure that your theme is the active one.
    (i know that sounds too basic, but I’ve seen it happen)

    Forum: Fixing WordPress
    In reply to: Main Menu Bar

    There is no “Max navigation elements”. In theory you should be able to add as much as you want. You would just have to ask yourself if it’s userfriendly and functional.

    It looks like you’re using a premium template from https://themify.me/ , you should contact them for support as their theme may have a bug.

    Hi Danielle,
    I just checked out your site and it looks like the video is opening and playing in lightbox, were you having another issue with this?

Viewing 15 replies - 1 through 15 (of 74 total)