PHP wordpress style related posts - php

Do you know how wordpress decides which related posts to show?I mean I know if it has tags, then it's easy but if it doesn't?
Best Regards,

Generally the 'related post' function of a Wordpress Blog is created by the owner of the blog, or using a plugin. I can imagine that those plugins either look for new posts with similar tags or in the same category as the post it is displaying.
As far as my knowledge extends, I do not believe that Wordpress has a show_related_posts function, although I may be wrong. If it does, it would be simple enough to look it up on the documentation at wordpress.org.
Also, another good part about OpenSource programming is that you can simply go in and look at any of the code that you are curious about. I personally use Notepad++, and when I find a function in Wordpress or any other CMS I am not famillar with, I simply copy and paste the function name, and do a Multi-File search on the function to figure out where it is declared.

I'm going to have to go with Chacha102, as far as I know this can only be done using plugins or by hacking the code yourself.
I did something similar by falling back on the post's category if it had no tags, works pretty well too.

This guy has the leading plugin for related posts. I'd download that and take a peek at his code and see how he does it. Then you can reverse engineer it and make it your own. The beauty of opensource.
http://wordpress.org/extend/plugins/wordpress-23-related-posts-plugin/

Related

Wordpress method to parse existing posts

I have a WP blog with over 7500 posts and would like to run a "batch script" on all such posts, to apply some changes to each post's content. For example filter some words or reduce the number of characters/images etc.
I'm familiar with PHP, but I'm not really familiar with Wordpress and the WP Codex. I know what I need to code once I get access to the actual post content, but getting there and after that saving the new content to WP DB is what I don't know how to achieve.
What is the best (straightforward & easy) option - running some batch script through PHPMyAdmin or is there some WP plugin that can be modified to achieve arbitrary operations on posts' content?
Does anyone have such a batch script in their workspace, willing to share?
I finally found it by testing, and again "thanks dude" to the one who downvoted the question without answering, just because.
So, the way to parse WP posts (just for visitor output, without altering in wpdb) is to go to "/wp-includes/post-template.php" and alter the internals of the_content function, before the echo $content statement. That's the most straightforward, yet unsafe way (if you don't know what you're really doing). Another safer way is to actually use the apply_filter(the_content, 'your_filter') filter hook if you know your WP stuff.
That's it, happy PHP-ing!

Replace word in Wordpress back office

I am using a theme that has a lot of tools I need for a project, the only issue is they have a really long company name and it is everywhere! The double lines are driving me mad.
I know how to replace a string on the frontend using the below code, but I dont know how to modify it for the admin area.
function replace_content($content)
{
$content = str_replace('##Replace Me##', '##With Something Else##',$content);
return $content;
}
add_filter('the_content','replace_content');
As far as I know the admin section doesn't have anything similar to the_content to filter off of, since any plugin/theme/extension could be writing to the backend in any way they want. You could probably find a good number of hooks to filter it out in most places (maybe the theme itself provides such hooks?) like you do with the content, but probably couldn't get all of them.
Given the way theme authors like to write their c̶r̶a̶p̶ code. I'm guessing this is hard coded into the theme, in which case the most viable option is unfortunately to edit the theme. If you can ssh into the server, command line tools like sed should make this basically a one-liner like the answer to this question.
If they happened to be nice enough to put their name in the database, you can use a plugin like Search & Replace to change all instances of it in the db.

Social Sharing Buttons Not Working in custom WordPress theme

I have of late been developing a custom WordPress theme for my own blog from the ground up! Most is not finished but my social sharing buttons are not working at all!
I have been using this tutorial....
http://www.jqueryscript.net/social-media/jQuery-Plugin-To-Customize-Social-Share-Buttons-Counters-SocialShare.html
and gone over all of my code with a fine tooth comb! I even tested it on a testing page and it's working fine there so i have no idea why it's not working on the actual theme!
I got a feeling it has something to do with my functions.php page as none of my widgets work in my sidebar which i have overcome by adding the custom code there! So i probably have to add some more code to my functions!
Also just to let you know eack of the buttons and their counters are contained within a div I made just below the_content and above the comments_template on my single.php
I am also running WordPress Version 3.9.1 if that helps
Any help would be greatly appreciated!
Phillip Dews
Without any examples, fiddles or code samples, it is impossible to assist. Having had a fair bit of experience with WP, this will be very difficult to help you with, unless you can provide a live site to look at. Even then, may be challengin' :)
Looking at that page you linked, your problem is almost certainly php-based, not jQuery. If your functions don't work and you're adding php code directly to your sidebars, then yeah, absolutely php.
A couple of things I can think of though that are commonly problematic:
Check/test/debug your functions.php file by itself. Make SURE it's rock solid.
If you're developing heavily, setup XDEBUG. Invaluable!
If you're mostly themeing, check out the debugbar plugin.
Of course, you'll always want to make sure you're using the template hierarchy correctly (http://wphierarchy.com/). Double check every path you use, specifically the differences between paths to load stuff from themes -vs- child themes:
http://codex.wordpress.org/Child_Themes
http://codex.wordpress.org/Function_Reference/get_template_directory_uri
http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri).
Oh yeah: functions.php in child themes loads in addition to the parent's functions.php, it does not replace it.
Hopefully something in here helps.

get latest posts from wordpress blog based on tags and display them in base site

this might be easy question for you but not for me as i am really new to wordpress, i have setup Wordpress in my site as blog(and i am quite happy with that),
i want to display some posts from my wordpress blog to my base site, i am looking around but its like headache as i have thousands of references and i am confused,
i want to display posts from certain tags,
any help would be much appreciated. Thanks in advance
Kind Regards
I use a program called rss2html setup with a category parameter. Costs a few bucks, but you can do practically anything with it (or via one of the companion programs available at same site). I have used it tons of times passing a category, custom query, or other parameter to it using the config file.
If you choose to pick up a copy and have questions configuring, gimme a shout, I've done literally hundreds of them.
You can find the program I use here: www.feedforall.com

Beginning to use wordpress, custom theme?

I'm pretty new to wordpress (only a couple of days), but I have it up and running on my website with the default theme. First of all I would like to change this theme. I have found a tutorial directly from wordpress but it is extremely vague: http://codex.wordpress.org/Theme_Development. I'd like to have a totally different layout for my website though, with only one page being replaced daily with a different article - a new article everyday basically. But I don't know where to start. I want to first create the theme though, I think that will put things in to perspective. How do I do so? I know the principles of php and enough about html and css to create whole websites. Thank you
That link should tell you everything you need to know. You basically just edit the theme files to get the layout that you want. The best way to learn truly is to experiment. If you have a specific question I could help you with that, but to tell everything involved in creating a custom theme would go way beyond the scope of an answer for this site.

Categories