Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • pdonnelly: I had the same problem and found a working solution.

    I am using Magic Fields and have three different Write panels, for three categories of posts. Two of them I wanted to order alphabetically (Artists and Discography) and the other (News) I wanted chronologically.

    Here’s the code:

    function set_post_order_in_admin( $wp_query ) {
    $customwrite = strstr(curPageURL(), 'custom-write-panel-id=');
    $admincatid = substr($customwrite, 22);  								
    
      if ( is_admin() AND $admincatid != '3') {
        $wp_query->set( 'orderby', 'title' );
        $wp_query->set( 'order', 'ASC' );
    
      }
    }
    add_filter('pre_get_posts', 'set_post_order_in_admin' );

    Magic Fields adds “custom-write-panel-id=1” to the end of the URL to define which custom write panel the administrator is currently editing. So this code checks the current URL with “curPageURL()” and then strips the URL string from everything before “custom-write-panel-id=” with the php function strstr.

    Now the variable $customwrite is “custom-write-panel-id=3”. And then I strip this variable from the 22 first characters, leaving only the number. And then I check so that the plugin only order by title as long as the custom-write-panel-id is NOT equal to 3 ($admincatid != ‘3’), which is the number for News.

    Forum: Plugins
    In reply to: [NextGEN Gallery]
    Thread Starter jteg

    (@jteg)

    Solved it:

    <?php

    /* Strip Pagelink from everything but the gallery-ID-number */
    $num = ”;
    $string = $gallery->pagelink;
    $string = ereg_replace(‘gallery=’, $num, $string);
    $string = ereg_replace(‘page_id=3’, $num, $string);
    $string = ereg_replace(‘album=1’, $num, $string);
    $string = ereg_replace(‘&’, $num, $string);
    $string = ereg_replace(‘amp;’, $num, $string);
    $string = ereg_replace(‘[/?]’, $num, $string);

    /* Post all galleries into the_content through apply_filters*/

    $showgal1 = ‘[nggallery id=’;
    $showgal2 = ‘]’;
    $showgallery = $showgal1.$string.$showgal2;
    $showgallery = apply_filters(‘the_content’, $showgallery );
    echo $showgallery;
    ?>

    Sometimes asking a question is just what it takes to solve the problem.

    <?php
    if (get_option('sticky_posts')) {
    
    // Do this if there is any sticky post.
    
    }
    
    else {
    
    // Do this if there isnt.
    
    }
    ?>

    wprabbit: Did you solve your issue?

    I have the same problem: if there’s no sticky post the loop is returning 10 regular posts.

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