WordPress.org

Ready to get started?Download WordPress

Forums

wp_list_pages getting wrong site (6 posts)

  1. gkbenji
    Member
    Posted 2 years ago #

    Posting here as the multisite element of my problem seems the most relevant. I'm using CKEditor with the MTC CKEditor Link Page plug-in. (I could query the plugin creators but it's simple enough I can hack it myself if I can figure out what's going on.) It's supposed to easily allow you to grab a link to an existing Page on your site.

    It does this by creating a page using wp_list_pages(), then some short javascript to return the page URL when you click.

    The problem? The page generated by wp_list_pages() always seems to list the pages of the "main" site I created first, and not the site I'm currently logged in to and editing.

    Here's the key bits of the plugin:

    window.onload = function() {
    			var atags = document.getElementsByTagName("a");
    			for(var x in atags) {
    				atags[x].onclick = addLink;
    			}
    		}
    	</script>
    </head>
    <body>
    <?php wp_list_pages(); ?>
    </body>

    Why would wp_list_pages() not return the pages of the site I'm actually working on? I'm stumped.

    FWIW, my site is http://www.rivendell-school.org/physed

    The "main site" is the root, http://www.rivendell-school.org/index.php (you need the .php because it's sitting on top of the existing site and the index.html gets served up first).

  2. Looks like someone else had this issue: http://stackoverflow.com/questions/5241810/wp-list-pages-displaying-pages-from-a-specific-wordpress-site-network

    That's ... odd. It doesn't act that way when used in a theme (and I would actually not use switch to blog myself)

  3. gkbenji
    Member
    Posted 2 years ago #

    My problem is actually the opposite... when I'm on a "sub" site, it's actually listing the "main" site pages!
    Hmm... I do use the switch_to_blog(1) trick in my theme template header header.php, like so:

    <?php switch_to_blog(1); ?>
    				<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
    				<?php restore_current_blog(); ?>

    The page being generated in the plugin doesn't use the templates at all, but could there be some strange interaction?

  4. This plugin: http://wordpress.org/extend/plugins/mtc-ckeditor-link-page/

    Stupid question. With the normal add a link tool in WP, you can search for and add a page. Does that have the same problem?

  5. gkbenji
    Member
    Posted 2 years ago #

    Yes, that's the plugin. The default WP editor does not have the issue--search for a page and it shows only the pages on the sub-site. TinyMCE did not cause the issue either, although I think it uses the default editor's link function.

    Honestly, the MTC CKEditor Link Page function is pretty kludgy and I can live without it. I'm just mystified why it doesn't work on a multisite installation.

  6. Yeah, that's a new one on me too. Nothing in the code looks like it should do that.

Topic Closed

This topic has been closed to new replies.

About this Topic