Community Forums › Forums › Archived Forums › General Discussion › Seeking plugin/code to maintain 2 sets of posts
- This topic has 39 replies, 4 voices, and was last updated 11 years, 1 month ago by dwogahn.
-
AuthorPosts
-
January 15, 2013 at 2:11 pm #12096dwogahnMember
Bill, this is great! Thanks! One tiny thing is that it is adding a second image in category view....perhaps b/c I noted in my instructions that i wanted to keep the 300x300 image. I should have said that I want the default 300x300 only. This image is an affiliate link. How do I show only the image with the Aff link?
I've left it "broken" on my site for now so you can see: http://www.sellbox.com/category/project-gallery
Thanks.
January 15, 2013 at 3:12 pm #12113Bill MurrayMemberI'm guessing you put an image in the post content with an affiliate link. That's fine. However, there is a separate image that can be controlled in the archive. The image from the archive can be easily removed with the PHP code below:
remove_action('genesis_post_content', 'genesis_do_post_image');
The image in the post content is harder to remove automatically. That means if you opt for the easy way out now by adding that line, you'll have a hard time if you ever want a content archive for this category without the image. On the other hand, if you want to put in more time to preserve future flexibility, you can add your affiliate links to each image in your media library for this category. Then, after testing 1 image and confirming the affiliate link works, edit 1 post to remove the image from the post content. If you're happy with the result, edit the rest of the posts. That should leave you with 1 image on your archive for this category which will be easy to remove if you decide to alter the category presentation.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 15, 2013 at 4:09 pm #12135dwogahnMemberHaving a little trouble with this. For code placement, am I to add this in the file category-X.php along with the other remove_action lines? Seems so but just confirming.
I'll likely opt to keep things flexible for the future but I'm getting stuck. I think its basic WP stuff.
"...you can add your affiliate links to each image in your media library for this category. "
When I go to Media Library, find the image, I don't see a place to add the affiliate link. I must be missing something. I used Upload/Insert to add the image and dropped the affiliate code in there. This is the one you say to delete, I believe.
January 15, 2013 at 7:21 pm #12176Bill MurrayMember1) Yes, add it with the other remove_action lines. Order shouldn't matter.
2) My error. Sorry. I can barely tolerate WP's media library, but sometimes I'm in a generous mood and give it more credit than it deserves. This is one of those cases where that led me to giving you bad info. WP only allows you to specify the Link URL when you insert an image into a page/post as you've done, and that's how you set up your affiliate link. Because of that limitation, you can't have the flexibility that I outlined. Therefore, you should just leave the posts as they are (less work!) and add that remove_action to the category template. That should remove the 1st image, which is not the affiliate link, leaving you with 1 image, which is the 1 you want.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 15, 2013 at 8:00 pm #12183dwogahnMemberAdded without problem. I kept your cautionary notes in my changes file just in case that becomes an issue in the future. I think this resolves my current need. Batman, should I need you again, how shall I find you?
January 16, 2013 at 12:14 am #12228Bill MurrayMemberGlad it worked for you. I wander around these forums as time permits. Among other things, I run a performance-oriented managed WP hosting environment where you can get ticket-based email support for customizations like this. In setting that up, I've learned a lot from the WP community, so as time permits I try to answer a few questions at different forums like this as a way of helping to build that community. Unfortunately, there are never enough hours in the day.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 16, 2013 at 12:31 pm #12357dwogahnMemberThis reply has been marked as private.January 16, 2013 at 1:38 pm #12378Bill MurrayMemberIf you were intending that I would see your last comment, you marked it as private, so it's only available to moderators, and I'm not a moderator. I've seen this elsewhere in the forum, and I think participants imagine that the reply is private to the previous responder, but that's not how it works.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 19, 2013 at 8:23 am #13069dwogahnMemberI'm back with a couple odd problems. Excluding a category ID in Theme Settings doesn't seem to work. Right now I have it set to exclude my #35 (Project Gallery).
I added a file called category-35.php per the above post (#12011). This is set to show 5 full posts at a time. I currently have 49 posts in category 35. When set for 5, I get a 404 error when I click forward to page 7. So, the first 5x6 posts show (30) but that's it. (The same thing happens if I set it to 4 only I can't get to page 8.) If I edit the php file to display 7 posts per page I can page forward through all posts. Same thing if I set it to 8 posts per page.
Right now I have it set to display 6 posts which works until page 7. Page 8 and forward results in a 404.
January 19, 2013 at 9:22 am #13077Bill MurrayMemberOn the 2 issues...
1) Excluding the category via theme settings: This only works when using the blog template. So other WP loops aren't affected. To get around that, you can use the code from this Gist. You'd add that to your child theme's functions.php but remove the opening PHP tag in the Gist, as your functions.php already has one.
2) My template was a "quickie", and I didn't mention a limitation inherent in the method I choose (only for speed of typing). If your posts per page in WP Settings->Reading is above the posts in this template, you will see this behavior. However, now that I have a better handle on what you want, I can adjust the template using a different method to query posts. Hopefully, I'll some free time this weekend.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 19, 2013 at 2:11 pm #13138Bill MurrayMemberWeird forum behavior. I just made a post with the changes you need to make, but it's not displaying. Unfortunately, I don't have the time just now to re-type it, but I'll check back later this weekend.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 19, 2013 at 4:24 pm #13171Bill MurrayMemberHere are the adjustments that should a) resolve the 404 error, b) fix the pagination, and c) remove category 35 from your home page loop. First, remove the category exclusion from your theme settings. Next, make sure your have a working backup of your child theme functions.php and FTP access to your site. This involves edits to that file, which if done incorrectly, can break your site. You can quickly fix that by deleting the bad functions.php and copying the good one in its place. Only attempt this if you're comfortable doing it and can fix something if it breaks.
1. Revise your custom category template to this:
<?php /* Category template for Genesis framework to display 5 full posts Author: wpPERFORM.com To use, put a copy in child theme folder and rename to category-xx.php where xx is replaced by the numeric ID of the category to which the template applies. */ remove_action('genesis_post_content', 'genesis_do_content'); remove_action('genesis_post_content', 'genesis_do_post_content'); remove_action('genesis_before_post_content', 'genesis_post_info'); remove_action('genesis_after_post_content', 'genesis_post_meta'); add_action('genesis_post_content', 'custom_content_limit'); function custom_content_limit() { the_content(); } genesis();
2. Edit your child theme's functions.php to add this code near the bottom, before any closing tag (if one exists):
// credit to Bill Erickson, see http://www.billerickson.net/customize-the-wordpress-query/ // excludes category 35 from home page main query add_action( 'pre_get_posts', 'be_exclude_category_from_blog' ); function be_exclude_category_from_blog( $query ) { if( $query->is_main_query() && $query->is_home() ) { $query->set( 'cat', '-35' ); } } // sets 5 posts per page for category 35 add_action( 'pre_get_posts', 'wpp_child_before_loop' ); function wpp_child_before_loop ( $query ) { if( $query->is_main_query() && !is_admin() && is_category( '35' ) ) { $query->set( 'posts_per_page', '5' ); } }
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 21, 2013 at 11:39 pm #13662dwogahnMemberThanks Bill. I removed the category exclusion and did the back and got the following error after making the change:
Server error
The website encountered an error while retrieving http://www.sellbox.com/wp-admin/theme-editor.php?file=functions.php&theme=education&scrollto=1400&updated=true. It may be down for maintenance or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.Note sure if the order matters, meaning, I updated the category-35.php file first, then the functions.php. I set everything back the way it was.
Let me know if I should check something else.
January 22, 2013 at 12:13 am #13665Bill MurrayMemberMy previous post has an odd history. After posting it, it didn't appear, and the next day, I came back to re-post it and it was there, so I suspect the post ended up in a spam queue, and someone rescued it. Looking at the code, it's not exactly how I posted it.
On the lines starting with if..., after is_main_query(), there should be 2 ampersands together, not separated by a space, instead of the & followed by a semicolon. In other words, you are replacing each & followed by a semicolon with a single ampersand, so that you have 2 ampersands back to back. It is a total of 6 replacements. Give that a try (again with a working backup), and post back. If that fails, I can post the code and provide a link. The forum software here alters the code, and the post getting flagged as spam didn't help.
500 errors are almost always PHP errors, so if those changes aren't the source of the problem, it could have been a mixup on copy/paste. But if you just copied the code as it appears in my previous post, that's likely the source of the error.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 22, 2013 at 11:58 pm #14002dwogahnMemberIt worked! Great instructions. The only thing I needed to do was add the line of code to kill the duplicate image file but we went through that before so it was easily done. Thanks for all your help. I'll leave this thread open for a few days in case my usage turns anything else up.
January 23, 2013 at 12:19 am #14003Bill MurrayMemberGlad it worked for you. You covered a lot of ground in these posts; you'll be writing custom templates for others in no time.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
January 23, 2013 at 11:56 am #14077dwogahnMemberNot only did I get a chance to geek out a bit but the exercise gave me some strategy inspiration as well. This thread has been an invaluable education. Thank you.
February 7, 2013 at 8:38 am #18661dwogahnMemberI've been assigning tags to all my posts but one category (my project gallery) dominates the tag cloud. Short of deleting the tags associated with posts in this category, are there alternatives? Sub categories?
February 7, 2013 at 9:55 am #18672Bill MurrayMemberAre you talking about your site http://www.sellbox.com? If I understand you correctly, you are saying that the tags you put on posts in the My Project Gallery category dominate your tag cloud. That's just a natural outcome of something such as a) having more posts in that category compared to others, b) having more taggable content in that category, or c) something along those lines. You don't want tags & categories to completely overlap; otherwise, there would be no point in using 2 taxonomies.
Categories are normally fewer in number than tags. You'll want to develop a strategy for how you'll use categories vs tags. For example, you might have a site where Politics is a category and you could use tags for people & events. Under that scheme, you wouldn't want to create a category for an event, because tags cover that. Generally speaking, when you see overlap or duplication in categories & tags, it's an indication that your strategy for using the 2 different taxonomies needs to be better clarified.
You also have to be careful with tag clouds because they can be resource hogs, especially if you have a lot of tags. A lot of people misunderstand the benefit of tag clouds. They typically do NOT help visitors find content in the traditional sense of searching; after all, any content that you tag with "blue" likely has "blue" in the post content, so a search on your site for "blue" will return that content. Tag clouds help visitors DISCOVER content in that while on your site reading about "apples", a visitor can discover your content on "blue" because he is drawn to the larger font of the tag in the tag cloud. If you didn't aid this content discovery, the visitor might leave without ever realizing that you covered more than "apples". Therefore, your choice of tags has to be guided by what you think will cause your visitors to explore further. If you pay the price of a performance hit from having a tag cloud, you have to get the benefit of longer, deeper visits.
Btw, since this topic isn't really related to your original question, you'd benefit from starting a new thread with a good description for this type of question. That would encourage more readership, which might lead to more diverse responses.
Web: https://wpperform.com or Twitter: @wpperform
We do managed WordPress hosting.
February 8, 2013 at 12:03 pm #18964dwogahnMemberThanks for the detailed feedback. What I am experiencing is the unintended result of adding and organizing this new collection of content, which is extensive relative to my more editorially driven posts. As a matter of strategy I realize I don't need to tag this category of posts. In fact subcategories might be even better.
I originally posted here b/c it relates to using Posts to profile a unique set of content. I'll keep that in perspective when it comes to using other WP features and widgets.
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.