Last year i've created a website with the Wordpress theme Let's Travel. I now have an issue regarding the displayed search results and I hope someone has a solution. The search results look like this:
Screenshot Searchresults
Looks ok, but i've marked the part that I don't want in there. That are the titles of the tabs on the actual page. I just want the first part of the actual text showing here. Or, even better: make this a custom excerpt (so it's using the excerpt you can create on every page by yourself).
The code providing this piece of information, looks like this:
<?php print wp_kses_post(Letstravel_TPL::clear_urls( wp_trim_words( wp_strip_all_tags(do_shortcode(get_the_excerpt())), 20 ) )); ?></p>
I've tried all kinds of different options with this code, but nothing seems to work. Does anyone have any tips regarding this issue? I am not very familiair with php, so I'm sorry if this is a very easy question :)
Thanks!
Related
My friend started a blogging website using wordpress for students to write on topics like world affairs, british politics etc. He is a philosophy student so himself doesn't any coding or web development and hence asked me since I'm doing a computer science degree to help him modify the search on his website. Basically the issue is that the search works normally except when you want to use it to search by articles written by a specific author. For example if you write the name of a person, all the articles written by him/her should be displayed. I have no experience in web development but watched loads of videos on youtube on how to customise the search but most of them just show to change its position on the page or just how it looks and none the way I want to specifically customise it. Are there links to any videos on youtube or articles that explain how to do it or what should I do to customise the search in this way?
I have been telling him for the past week that I will help in because I was confident I would have solved the problem but since I actually started trying the past couple days, I've seen so many ways it could go wrong from ftp to messing up the whole website. I'm sure if it's not clear enough or my question is stupid, I thought for a while before posting this on stack overflow.
MODIFY YOUR THEME’S SEARCH.PHP FILE
What we want to do is first take a look at the current search results page. If your theme is not presenting a search bar to make an actual search query, then you can simply append the following to your site’s URL : yoursite.com/?s=your+search+string.
Passing this query will send you to the search results page. Ideally your query should actually produce results so you could try to use a general search phrase that you know will produce multiple results.
Once you have a good idea as to how the results looks now, you can visualize a clear direction as far as how you want it to look. The search.php file usually starts with the following link :
this link
So, I've read The Loop and I got the hang of it. (I created a page that lists the 3 most recent posts, a page that shows a page (as opposed to a post), and so on.)
However, it seems silly that, in order to integrate a WordPress blog into an existing site, I'd have to replicate all the different kinds of pages (lists of posts, the posts themselves, pages, etc.)
Is there a generic way of doing this?
The full idea is something like this.
The blog itself (with its ugly default template) is installed at http://blog.example.com.
I want to integrate the blog into an existing site, at the URL http://example.com/blog.
I'm doing a mod_rewrite that forwards the entire query string, e.g. http://blog.example.com/?p=7 gets rewritten to http://example.com/blog?p=7.
Now, in my PHP code at http://example.com/blog, I want to do something like this:
query_posts($_GET);
// display results
wp_reset_query();
That's where I'm stuck. Basically, I want to display exactly what's in the "content" area of a default WordPress template, on my site, according to whatever the query string dictates. Almost as if I were just using an iframe. I would rather not have to parse the query string to figure out whether I have to loop through this or that or turn off the $more global or not, etc.
What am I missing?
Instead, should I be installing the blog at http://example.com/blog and creating a template that mimics the website? This seemed complicated so I didn't go this route, but maybe someone should change my mind.
Appreciate any help, including advice for alternative designs.
Have you considered outputting the blog into a full rss/ outputting the blog as json and then pulling it in that way?
I have taken over the development of a website and have written a simple page hit recording script that I've placed in the header.php of the theme. It seems to work great except when visiting the base url of the site. Then, it records two hits, one has the correct url (www.idataresearch.com) but the other one looks like www.idataresearch.com/page/2/. Both hits have the wrong page title recorded as well. I have a feeling it's something to do with the loop or the way the template loader is working. Any help would be greatly appreciated.
I have no idea why it's doing this but I've decided to just filter out those weird extraneous results. The site seems to be working well otherwise ...
I'm frequently checking a blog for the most recent news, and I hate always going to the homepage for the most recent post, sometimes because of the cache stuff the most recent post won't display on the homepage for 10 minutes or so.
So if I want to get the most recent post as soon as the post is published, is there a direct link for the most recent post? Maybe like http://exampleblog.com/?p=most_recent ?
Well I've tried several ways like RSS feeds, nothing works. Anybody knows how to do this?
Thanks
There are a few plugins that can do this or you will have to code a page to do it. There is no prebuilt page or url. One plugin is "Recent Posts 2.6.2.0" (many more like it) and it is for wordpress and can be viewed by going to something like yourblog.com/recent-posts. Or if you prefer to hand code a solution a good guide can be found by going to http://keirwhitaker.com/archive/wordpress-get-latest-post-url-function/
EDIT
Code to retrieve blog posts from rss. PHP code I have used and can modify the code just to get one post
<?
include("rssreader.php");
$url="http://www.blog.com/feed/";
$rss=new rssFeed($url);
if($rss->error){
print "<h1>Error:</h1>\n<p><strong>$rss->error</strong></p>";
}else{
$rss->parse();
#$rss->showHeading("h1");
#if($rss->link){
# print "<p>Provided courtesy of:<br>\n";
# print "$rss->link\n";
#}
#$rss->image->show("middle");
#$rss->showDescription();
$rss->showStories();
}
?>
and the rssreader can be downloaded at http://apptools.com/phptools/downloads/rssreader.zip
I am very new to WordPress, so I would appreciate some help.
I am using WordPress as a CMS, and I am trying to make the thing work so that when I select a page to edit, there is a special box where I can input PHP code that will execute on my page.
I have found the PHP exec plugin, which works perfectly, but I would like to keep the code out of my main text editor, out of the way of my client's careless fingers.
Any suggestions would be very, very appreciated. Thanks!
You could create a template for each one, and include your PHP there.
Simply select the template from the page edit page.
But if you are only including a little PHP per page, you could get the slug via WordPress in your page template and act on it accordingly.
You can also add an extra meta box on the post editor page, only visible to you, with a textarea where you can add the code. You would save it as a meta field of the post. Your template can check for the existence of this field, and execute it if found.
PHP Exec is the best plugin I have found, and I looked long and hard for that one. The problem with doing it as you suggest is that if the PHP code displays an item on the page, it still has to be formatted within the page as well. It is a simple logistical problem, but somewhat of a complex coding problem. I haven't been able to get around to working on creating a better plugin for it.