Forum Replies Created

Viewing 13 replies - 1 through 13 (of 13 total)
  • Forum: Fixing WordPress
    In reply to: Upload Button

    It’s at the top of the post box. Where it says: Add Media. Click on one of those buttons and you can upload a file. Is that what you meant?

    Thread Starter doppledoer

    (@doppledoer)

    I forget if I was on 2.3.1 or 2.3.3 but it did it automatically for me.

    I HAVE tried it on 2.5, that is my whole problem. It doesn’t work. It handles dates fine, but not post title.

    Interestingly, i have found that if I choose to save just under post title, it fails this and the file ends up in the base folder. However, it also creates the following directory: base/year/month/day/post_title which is empty. There seems to be a mismatch between creating directories, the options chosen and the saving of the file. That might come in handy for anyone attempting to fix this.

    OTHERWISE: Does anyone have ANY idea how to allow files to be uploaded to base/post_slug? I don’t care if it’s an ugly hack. Any ideas would be great.

    Cheers

    Thread Starter doppledoer

    (@doppledoer)

    It did it automatically for me on 2.3, not sure why it isn’t working for you.

    This custom upload directory is the last thing lacking from my upgrade to 2.5. Any help with fixing it would be GREATLY appreciated

    Forum: Fixing WordPress
    In reply to: Remove browse tab

    Longhair, thanks for the tip, but there is a mistake in your code. You left out the second right bracket after ‘import’. For anyone else, copy and paste this instead. It works great.

    if ( $pid ) {
    	// 0 => tab display name, 1 => required cap, 2 => function that produces tab content, 3 => total number objects OR array(total, objects per page), 4 => add_query_args
    	$wp_upload_tabs['upload'] = array(__('Upload'), 'upload_files', 'wp_upload_tab_upload', 0);
    	if ( $all_atts && $post_atts = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_parent = '$post_id'") )
    		$wp_upload_tabs['browse'] = array(__('Browse'), 'upload_files', "wp_upload_tab_browse", $action ? 0 : $post_atts);
    	if ( current_user_can('import'))
    		if ( $post_atts < $all_atts )
    			$wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
    } else
    	$wp_upload_tabs['browse-all'] = array(__('Browse All'), 'upload_files', 'wp_upload_tab_browse', $action ? 0 : $all_atts);
    Thread Starter doppledoer

    (@doppledoer)

    In case anyone else arrives here with the same problem, here’s the solution: Adapt this template to suit your various needs, but replace the database call with:

    $querystr = "
        SELECT wposts.*
        FROM $wpdb->posts wposts
        WHERE wposts.ID NOT IN
          (
          SELECT wpostmeta.post_id
          FROM $wpdb->postmeta wpostmeta
          WHERE wpostmeta.meta_key = 'YOUR_KEY'
          )
        AND wposts.post_status = 'publish'
        AND wposts.post_type = 'post'
        AND wposts.post_date < NOW()
        ORDER BY wposts.post_title ASC
    Thread Starter doppledoer

    (@doppledoer)

    In reality, I want a list of posts where the column ‘custom_key’ does not exist. However if I write:

    AND NOT wpostmeta.meta_key = ‘custom_key’

    it returns an entry for every column in every post that isn’t ‘custom_key’, far from what want. I’d like to call a unique list of every post and then eliminate all the ones that have a ‘custom_key’ column.

    Thread Starter doppledoer

    (@doppledoer)

    No, I’m not testing against a specific value. I just want a list of the posts where I haven’t entered a value at all, so I know which need attending to.

    Thread Starter doppledoer

    (@doppledoer)

    I discovered the problem. I didn’t realise dropdown lists had to be written as optionA,optionB,optionC rather than optionA, optionB, optionC. All good!

    Thanks Henrik. I really appreciate it. Although I must admit, I’ve already got some more issues that I’ll probably be bothering you with in the very near future. Sorry!

    Thread Starter doppledoer

    (@doppledoer)

    Ok so I tried it and it worked, but only for the first choice in list ie the ‘nobody’ category. Perhaps it is interfering with the subsequent javascript. Is that what happens to you?

    Cheers (really sorry for all this trouble!)

    Thread Starter doppledoer

    (@doppledoer)

    I’m not getting any errors, it just isn’t doing anything. I’ll take another look,

    Thread Starter doppledoer

    (@doppledoer)

    Again, thanks for your help Henrik. However, I can’t get it to work for categories. My knowledge of Javascript and the backend of WordPress plugins is pretty thin, so I tried adapting the original Meta to Tag plugin you put forward, but without luck. Perhaps I did something obviously wrong? This is what it looked like:

    <?php
    /*
    Plugin Name: Meta to Cat
    Version: 0.1
    Plugin URI: https://labs.dagensskiva.com/
    Description: Creates a cat for a specific key created in More Fields.
    Author: Henrik
    */
    function set_cat_by_meta () {
    
      if (preg_match("/\/post/", $_SERVER['PHP_SELF'])) {
        ?>
        <script language="JavaScript" type="text/javascript">
        document.onload = p2m_init();
    	// Hook functions to the key
        function p2m_init () {
    
    $('rate_pop').onchange = function () {
    
      // Get the value in the select list
      var cat_value = $('rate_pop').value; 
    
      // The 'Nobody Cares' category...
      var nobody_cat_id = 'in-category-19';
      if (cat_value == 'nobody') $(nobody_cat_id).checked = true;
      else $(nobody_cat_id).checked = false;
    
      // The 'Mostly Friends' category...
      var friends_cat_id = 'in-category-18';
      if (cat_value == 'friends') $(friends_cat_id).checked = true;
      else $(friends_cat_id).checked = false;
    
      // The 'Decent Following' category...
      var decent_cat_id = 'in-category-16';
      if (cat_value == 'decent') $(decent_cat_id).checked = true;
      else $(decent_cat_id).checked = false;
    
      // The 'Big Puller' category...
      var puller_cat_id = 'in-category-20';
      if (cat_value == 'puller') $(puller_cat_id).checked = true;
      else $(puller_cat_id).checked = false;
    
      // The 'Stadium Filler' category...
      var filler_cat_id = 'in-category-17';
      if (cat_value == 'filler') $(filler_cat_id).checked = true;
      else $(filler_cat_id).checked = false;
    
      // and so on ...
    
    };
    
    }
    
          </script>
        <?php
      }
    }
    add_action('admin_footer', 'set_cat_by_meta', 11);
    
    ?>

    Know what might be wrong?

    Thanks

    Thread Starter doppledoer

    (@doppledoer)

    Thanks Henrik, it does the job nicely. Excellent work.

    The only problem is that I can’t work out how to adapt it so that it works for multiple custom fields (with the least amount of doubling up). I tried just copying various aspects of it, e.g. creating $the_key2 = ‘dsc_artist2’; etc. but it didn’t work.

    I’m also wondering if it is possible to do the same with categories? For example, I might create a category called ‘album’ and a custom field called ‘cd type’ which would be a drop-down list. If ‘album’ was selected from the list, that post would also be entered into the ‘album’ category. I imagine it would be similar to above.

    Of course, this could probably be avoided if there was a plugin out there that allowed you to choose categories on the ‘write post’ page using drop-down menus, or at least gave you more flexibility. Unfortunately, I haven’t been able to find one.

    Any help with this would be greatly appreciated,

    Cheers,

    Peter

    Thread Starter doppledoer

    (@doppledoer)

    I’m not really sure what you mean by ‘links to your category or tag archives’.

    Basically, I would like to display posts, depending on a custom field value. I could do this using this method, however it would be rather complex, especially if doing it for multiple instances.

    What I would like is for the custom field value to become a tag or category, so i could then use the query_posts function to quickly manipulate the output of posts.

    You may say ‘just enter the values in the tag box like everyone else’ but I have good reason for wanting to do this. It would make submitting posts to a strict standard much easier for inexperienced authors.

    So, anyone have ideas?

    Thanks in advance.

Viewing 13 replies - 1 through 13 (of 13 total)