WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Archives
options page for plugin not added (15 posts)

  1. newcom1
    Member
    Posted 3 years ago #

    I activated the plugin, but it didn't create the options page in the dashboard.

    It did extend wp_get_archives to include custom post types. That call, however, seems to generate the debug notice: "PHP Notice: Undefined variable: in" ... "custom-post-archives.php on line 766"

    The plugin code looks clean and well-documented. Unfortunately, it's a little bit above my level.

    Any suggestions for a fix?

    I'm running WP 3.1.1 on XAMPP, Windows XP.

    http://wordpress.org/extend/plugins/custom-post-archives/

  2. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Sorry I didn't get to this sooner, newcom1 - been a bit swamped with work, as of late.

    Took a look at the code indicated by your error, and I have to admit, I'm at a bit of a loss. There appears to be no apparent reason you'd get that type of error in that function. Not to say it couldn't happen - it apparently did D:

    If you happen to still have the plugin installed, could you check to confirm that the function get_bases is on line 759, and maybe do a print_r on $this->_rewrites, see what it spits out?

    To trigger that function, you'll need to hit 'save' on the permalinks page, seeing as you can't get to the options page for this plugin

    Speaking of which, this has become a real issue - you're not the first or last to mention the options page not showing up. It's become a bit of a pain really - I can't track down what the issue is, I'm actually using the recommended code for adding option pages verbatim. If you can tell me what additional plugins you have, or any other information that's valuable, I'd truly appreciate it.

    Thanks!

  3. newcom1
    Member
    Posted 3 years ago #

    Thanks for sharing your work on this plugin. I still got it installed, and it's generating my custom-post-type archives quite handily.

    I've got the function get_bases on ll. 786-795:

    public function get_bases()
    	{
    		$bases = array();
    print_r($this->_rewrites);
    		foreach($this->_rewrites as $key => $rewrite){
    			if($rewrite["base"] == "") continue;
    			$bases[] = $rewrite["base"];
    		}
    		return $bases;
    	}

    When I press save on the permalinks page, the print_r generates:
    Array ( [post] => Array ( [externally_set] => [in_default] => 1 [in_rss] => 1 [base] => ) [page] => Array ( [externally_set] => [in_default] => [in_rss] => [base] => ) [attachment] => Array ( [externally_set] => [in_default] => [in_rss] => [base] => ) [notes] => Array ( [externally_set] => [in_default] => [in_rss] => [base] => notes ) [refs] => Array ( [externally_set] => [in_default] => [in_rss] => [base] => refs ) [headings] => Array ( [externally_set] => [in_default] => [in_rss] => [base] => headings ) )

    For additional reference, here's my code line 766 that's generating the error I mentioned above:
    if(!$path) return;
    That's in private function set_queried_object($query)

  4. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Ah - ok. That makes sense. On line 764, add this last else statement:

    }else return;

    That should at least resolve the warning. Is there still no options page in the admin for you? How are you enabling the archives?

  5. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Ah never mind - you're calling wp_get_archives, I see. Makes sense.

  6. newcom1
    Member
    Posted 3 years ago #

    I added the else return; on l. 764 and now I'm getting three warnings: Undefined variable: post_type, line 775 (twice), Undefined index: [no key listed], line 777

    Yup, I'm calling wp_get_archives. I still don't see the options page. Maybe somehow I'm overlooking it. Where exactly should it be?

    By the way, I'm also running the Custom Post Type UI plugin:
    http://wordpress.org/extend/plugins/custom-post-type-ui/

    It creates a "Custom Post Types" top-level options page. Could there be some name space collision with that plugin?

  7. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Wow. Odd. It shouldn't even be getting that far, it was supposed to return on 764. I'm setting up some dev now, I'll see if I can reproduce and kill it.

  8. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    I wasn't able to replicate your errors, unfortunately. Used a clean install of WP, added a custom post type, and called wp_get_archives in the sidebar...am I missing a step?

    Either way, I've found the error for your missing configuration page - I wonder if the two are connected? I'll be pushing out an update with it later, but I'd like to see if I can track down this other issue first, if they're not. The solution is here.

    Thanks!

  9. newcom1
    Member
    Posted 3 years ago #

    Great work! Made that change, and bam, there's the options page.

    I'm still getting the PHP Notices "Undefined variable: post_type, line 775 (twice), Undefined index: [no key listed], line 777". I get these notice when I access my archive page. This is a page I created in a child theme using the Thematic Theme's archive template. While you probably know, in any case the Thematic theme is here:
    http://wordpress.org/extend/themes/thematic

    Here's the relevant section I changed/added to Thematic's archives.php:

    the_content();
    // action hook for the 404 content
    // thematic_archives();
    echo 'refs archive: <br />';
    $ga_args = array( 'post_type' => 'refs', 'type' => 'daily', 'show_post_count' => true);
    wp_get_archives( $ga_args );
    echo '<br/> notes archive: <br />';
    $ga_args = array( 'post_type' => 'notes', 'type' => 'daily', 'show_post_count' => true);
    wp_get_archives( $ga_args );
    edit_post_link(__('Edit', 'thematic'),'<span class="edit-link">','</span>');
  10. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Out of curiosity, can you paste the URL generated into one of those archive links? I wouldn't think that it's able to return anything if there's no archive for that post-type...

  11. newcom1
    Member
    Posted 3 years ago #

    Here's the link generated from the archives.php template page which does the wp_get_archives() call:
    http://localhost/wordpress/notes/2010/01/05/

    'notes' is the name of the custom post type

  12. Jacob Dunn
    Member
    Plugin Author

    Posted 3 years ago #

    Thanks, newcom. That links checks out...I'm stumped. Unfortunately, I'm still not able to reproduce the issue - I've used Custom Post Type UI on a clean install with your post types, and the config page intentionally disabled. No dice. However, I've added some more sanity checks throughout that function - we'll see if that fixes it. I'm pushing those updates live now.

    I'd also attempt enabling those archives via the settings page and saving, now that you have access to that. That may eliminate those errors, as well.

    Sorry I couldn't help more!

  13. newcom1
    Member
    Posted 3 years ago #

    You've been very helpful, and your plugin is great. Ignoring a few PHP notices from it is no problem.

    Just for coding interest:

    I updated those archives via the settings page. When I enable the archives via the settings page and save, I get:
    "Undefined index: base...line 107" six times
    "Undefined index: overloaded... line 288" / line 310 (pair six time)

    When I go to the archives.php template page, I get:
    "Undefined index: base...line 107" three times

    When I click on the wp_get_archives() link, I get:
    "Undefined index: base...line 107" three times
    "Undefined variable: post_type... line 775" twice
    "Undefined index: [no key]...line 777" once

    I've got three custom post types defined.

    If this isn't of interest to you, please don't worry about it.

  14. newcom1
    Member
    Posted 3 years ago #

    I may have corrupted some meta-data for the notes custom post types. In particular, in the admin edit view, notes show up sorted by title by default. I try to hook into manage_edit-notes_sortable_columns and change 'orderby' => 'date', but that doesn't work. That seems a little screwy to me. And definitely nothing to do with your plugin.

    Also, in functions.php, I've got this:
    add_action( 'thematic_archiveloop', 'otx_date_order', 5 );

    function otx_date_order() {
    if ( !is_tax( 'detail' ) ) {
    global $query_string;
    query_posts( $query_string . "&order=ASC" );
    }
    }

    I'd guess that isn't causing problems for your plugin, but thought you might like to know.

  15. newcom1
    Member
    Posted 3 years ago #

    I got the plugin update, and it works fine, although still producing the notices. I poked around a bit, and the problem seems to be that I have custom post types checked on the CPA options page, but not the default post types post, page, and attachment. My thinking was that I didn't need the plugin for archives for those post types. In generally, I'd rather not use a plugin where I don't need it.

    To kill the notices in any case, I changed config.php, line 107 from
    $setting['base'],
    to
    (isset($setting['base']))?$setting['base']:null,
    I also changed custom-post-archives.php from
    }else if($post_type){
    to
    }else if(isset($post_type)){

    I figure if I study your plugin code carefully I can learn a lot about using WordPress and object-oriented PHP. Still hoping to do that at some point.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic