Page 1 of 1

Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 6:11 pm
by BreKat23
Hi Guys!!

So all I'm trying to do is hide a single author from my sitemap. Here is my sitemap;

http://www.ineedlovetolive.com/sitemap/

I'm trying to hide 'INL2L' from under the Authors list.

I have no idea how to do, I am completely at a loss.

I'm using the SimplePress Theme, and I'm trying to edit the page-sitemap.php file in my editor but everything I've tried so far has not helped. Any assistance in this matter would be extremely grateful!! I've been trying to get this done for a few hours now lol.

Thanks! :)

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 7:06 pm
by requinix
Do you know if that sitemap page was added by your theme or whether WordPress creates it for you (and the theme customizes it)?

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 7:29 pm
by mecha_godzilla
Hi,

If there isn't an option to control this in the theme, you'll probably need to specifically exclude this "author" from the query using a filter in the script. It looks like this is a paid-for theme, so the developers should have a support forum or be able to offer you some level of assistance.

HTH,

Mecha Godzilla

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 7:41 pm
by BreKat23
Thanks for the replies!

Yes, I am using a paid-for SimplePress Theme, however I am no longer a member of eleganthemes.com (where I bought the theme from) - and thus, I haven't been able to get any assistance from them :(

The sitemap, I'm pretty sure, is a part of the theme - because when I go to make a new page, there are 'Page Attributes' option, which is from the theme, and under these options is a 'sitemap' option.

So, I do believe I need to custom code the 'INL2L' Author out, and I don't know how to do that, which is why I was asking here.

"you'll probably need to specifically exclude this "author" from the query using a filter in the script." -----that is exactly what I was thinking too, haha - but can anyone help me figure out how I can do this? 8O

If anyone can help me figure out how to do this I would be so happy, and send you all the positive, happy vibes I can muster haha - please let me know, and thanks so much!!!

-Bre

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 7:48 pm
by requinix
This is a bit tricky because, being paid for, copyrighted, and undoubtedly licensed code, you can't just post it in a public place like this. Which is what we'd normally ask you to do.

How are you with learning a bit of PHP? We can tell you what to do but first we have to find out.

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 7:56 pm
by BreKat23
Hmm, I see - I hadn't considered that... 8O

I'm really not the best at code (is that even what I should be calling it, haha) - I try my hardest to learn and teach myself what I can, and I've certainly improved quite a lot from when I started, but I still find it difficult at times.

Maybe I could PM the code to someone, or is that also frowned upon? :?

I'd be willing to grant someone access to my admin area and/or chat (either through here, which works fine) - or if preferred, I have a Skype account - to make things more fluent.

What if I just posted a snippet of my page-sitemap.php? The part of it that deals with I'm working with and not the whole thing? Would that suffice?

I'm not sure, but I'm willing to do whatever I can to fix this, and work with whatever and whomever can help me...

:cry: :roll: :?

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 8:31 pm
by requinix
Do you see any kinds of SQL queries? It'll use terms like "select" and "join" and "order by". Or another idea, take a look if you can see where the various authors are outputted - probably says "sitemap-authors" nearby with some <ul> and <li> HTML tags. There'll be a loop there, then look for places earlier in the file that reference the $variable (or variables) it uses. If you can find either of those things then that's what we're looking for.

Otherwise yeah PM should be fine. If mecha feels up to it then it's all his, otherwise I can try my hand at it. Or you can post the file and I'll cut out the stuff that's not relevant.

Re: Help With SiteMap Pretty Please? :)

Posted: Tue Jul 16, 2013 8:42 pm
by BreKat23
You're awesome... I really appreciate your assistance with this,

Mecha is helping me on another question I posted to the forums, haha - this one;
viewtopic.php?f=1&t=138104&p=686808#p686808

I don't wish to inconvenience or overwhelm you guys, truly!
Do you see any kinds of SQL queries? It'll use terms like "select" and "join" and "order by". Or another idea, take a look if you can see where the various authors are outputted - probably says "sitemap-authors" nearby with some <ul> and <li> HTML tags.
Where could I look to find such things? I'm really not sure haha, I wish I more knowledgeable on all this, I realize I probably come off as extremely non-self-sufficient, lol :|

If it's too complicated to explain or teach then I really don't mind sending you the code, either on here or through a PM.... I would just need to know which code you're looking for exactly (I think I'm hopeless, lolz!)

Would you need the page-sitemap.php? Or perhaps the functions.php or some other php? :roll:

I will deliver whatever it is you need to help me on this, haha - just let me know what I can do. I deeply apologize for being rather ignorant, but I'm learning! :P

Thank you for assistance, thus far - I'm eager to look into this more!

<3 <3 <3

Re: Help With SiteMap Pretty Please? :)

Posted: Wed Jul 17, 2013 1:44 pm
by BreKat23
Hope you (requinix)... or maybe someone else could still help me with this please... :cry:

Re: Help With SiteMap Pretty Please? :)

Posted: Wed Jul 17, 2013 3:24 pm
by mecha_godzilla
Bre - I've just PMed you about this.

M_G

Re: Help With SiteMap Pretty Please? :)

Posted: Wed Jul 17, 2013 3:30 pm
by BreKat23
Awesome, thanks! I shall respond momentarily :D

Re: Help With SiteMap Pretty Please? :)

Posted: Wed Jul 17, 2013 7:44 pm
by mecha_godzilla
For the benefit of anyone else that might have this problem:

The site map generated by SimplePress theme is populated using the wp_list_authors() function which can be found at /wp-includes/author-template.php and is therefore part of the WordPress codebase.

This issue with using this function is that the filter options are very limited - you can exclude all "admin" accounts for the list of post authors, but there is no facility to exclude a specific post author based on their user ID or display name.

The solution (which works with SimplePress) was to copy-and-paste the wp_list_authors() function and then find an appropriate script in the theme to put a renamed version of the function in, and then modify it to support the update. SimplePress has a "custom_functions.php" script specifically for this purpose, and the wp_list_authors() was modified as follows - just the first section of the function has been included as only two lines need to be modified in addition to the change of function name:

ORIGINAL CODE - wp_list_authors() function in /wp-includes/author-template.php

Code: Select all

function wp_list_authors($args = '') {
	global $wpdb;

	$defaults = array(
		'orderby' => 'name', 'order' => 'ASC', 'number' => '',
		'optioncount' => false, 'exclude_admin' => true,
		'show_fullname' => false, 'hide_empty' => true,
		'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
		'style' => 'list', 'html' => true
	);

	$args = wp_parse_args( $args, $defaults );
	extract( $args, EXTR_SKIP );

	$return = '';

	$query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) );
	$query_args['fields'] = 'ids';
	$authors = get_users( $query_args );

	$author_count = array();
	foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " GROUP BY post_author") as $row )
		$author_count[$row->post_author] = $row->count;
REVISED CODE - custom_wp_list_authors() function in /wp-content/themes/SimplePress/epanel/custom_functions.php

Code: Select all

function custom_wp_list_authors($args = '') {
	global $wpdb;

	$defaults = array(
		'orderby' => 'name', 'order' => 'ASC', 'number' => '',
		'optioncount' => false, 'exclude_admin' => true,
		'show_fullname' => false, 'hide_empty' => true,
		'feed' => '', 'feed_image' => '', 'feed_type' => '', 'echo' => true,
		'style' => 'list', 'html' => true
	);

	$args = wp_parse_args( $args, $defaults );
	extract( $args, EXTR_SKIP );

	$return = '';

	$query_args = wp_array_slice_assoc( $args, array( 'orderby', 'order', 'number' ) );
	$query_args['fields'] = 'ids';
	$authors = get_users( $query_args );

	$author_count = array();
	$excluded_author_id_list = '888'; // User ID to be excluded from results; use comma separated values if multiple users need to be excluded
	foreach ( (array) $wpdb->get_results("SELECT DISTINCT post_author, COUNT(ID) AS count FROM $wpdb->posts WHERE post_type = 'post' AND " . get_private_posts_cap_sql( 'post' ) . " AND post_author NOT IN ($excluded_author_id_list) GROUP BY post_author") as $row )
		$author_count[$row->post_author] = $row->count;
Note that it is also good practice to add the following code before/after your custom function to avoid function declaration problems:

Code: Select all

if ( ! function_exists( 'custom_wp_list_authors' ) ){
// function declaration goes here
}
The reference to this function is then updated in /wp-content/themes/SimplePress/page-sitemap.php by just changing the name of the existing function to the new one.

M_G

Re: Help With SiteMap Pretty Please? :)

Posted: Wed Jul 17, 2013 8:09 pm
by BreKat23
Ohh my, Mecha_Godzilla you are truly a beast with coding - all the code you posted above looks like this to me;

f;sj56 idsghi79sd agekt0'f alteksohd[9073 )(kgj (lat uid7ga90-)( tjed0g8..... and then some (lol). :lol:

Yet somehow, your explanation of it all, in a small way, made sense (for me). Still doubt I would have been able to do it myself though - you have worked wonders and I appreciate your help more than you know, you are very skilled in your expertise!!

:bow: