Download post as text file on wordpress blog post page - php

Is there anyway to download individual blog posts as text (or html) files ? I am trying to generate the markup for a html email based on the content of the blog post.
The content of the files would be the excerpt.
What would be the easiest way to generate these files? I am not sure how to approach this problem.

I've used Wordpress to generate email newsletter templates on like a dozen of the sites I've built.
Just create a new page template (see the associated Page Templates Codex page) designed with your markup for the HTML newsletter (usually very simple since most email clients have unbelievably shitty HTML/CSS support that's a solid decade behind the rest of the internet).
Then use template functions and a custom loop to get the blog post or other content from Wordpress you want, display it in the template, and then when you view the page you can just copy the HTML! Note that you probably want to write your own header and footer for this template to keep it slim (rather than using get_header() and get_footer().

Take the post body and do a strip_tags().

Related

wordpress page.php styling and markup

I have a couple of questions related to building a custom theme with Wordpress.
1) If the website is made up of pages, I can use page .php to run the LOOP and retrieve content. In this case, is it OK to paste the content (of each page) using the backend of word press - I.e. paste all content and HTML markup into the 'text; . Is this a reliable way to enter content and accompanying markup into the database?
I guess the advantage is that users will then be able to edit the content themselves using the visual Tab.
Many thanks,
P
Well this not a recommended way to do it, but yes the editor is there for the same purpose. I wont be using it this way, because in my experience wordpress editor often acts weird with html. By default auto paragraphs are enabled, so everything gets in its own paragraph, even if you disable auto paragraph it still has some issues. For instance if you add html in the text tab, and then goto visual tab and switch back to html, and save the same html, this time it would be styled differently. Secondly its also not good to allow users to add html from a security POV and you cant guarentee the consitency of the website.
I would recommend using custom fields instead and fetch these custom fields in the through your theme files.

Duplicate content on homepage of custom made PHP script

I coded a simple php blog. On the homepage it displays the most viewed post and also links to the actual page of the post similar to the frontpage of a wordpress blog for example.
How to avoid duplicate content for SEO purposes? Is there a certain html tag or code for search engines to prevent considering the post on homepage and the actual page duplicate??
Thanks
Homepage is the page that index.php or index.html outputs, even if this is a redirection to an inner file. If you want to make a cms for example with an admin panel and offer different templates, styles and plugins, and decide to divert the design code from the engine code, it is is functionally common sense that you 'll include the template in other template-folders (to keep the filesystem clean, well-organised, and easily accessible from the design work). In this way, admin panel will insert and update your site parameters to the database and the root index file will read those parameters from the db. So the best you have to do for SEO means is to create and keep well-informed all the xml files (sitemap, feed, rss, atom), include keywords (taxonomy),tags and metadata, coherence at internal and external links, keep a clean design output and a lot more parameters that needs a lot of space and time to analyze.

history.pushState navigation - what about meta tags - separate template?

i have been building a jquery navigation based site without reloads ( using PHP and AJAX ) and have recently come across the problem of page "back", "forward", and "reload" features as well as SEO friendliness.
--skip this section to get straight to question--
my site is currently (not using AJAX but ) loading a single index.php which has several "content" divs, one of which is visible (class="active") while the others are not displayed. When the user clicks a navigation link, a nice animation switches between content divs.
I have apache rewrites to map things like
http://mysite.com/about
to
http://mysite.com/index.php?page=about
where the "about" section would be the one thats displayed by default (while the other "content" divs are hidden). based on this parameter, i include the proper meta tags for the pages. my sitemap has mysite.com/about, mysite.com/blog so that they get indexed as nice separate pages.
However, I've recently decided to make this ajax-based since i plan to incorporate a lot more content and its stupid to load all content on one page.
Note: I'm also now implementing Smarty templates.
I decided to implement hash tags, but saw the inherent SEO problems, then i discovered hashbangs (wth?!) and then found the new HTML5 stuff with history.pushState() and History.js and have decided to use it.
so here comes the main question
if i have just one page which loads page templates in a content div with ajax, using history.pushState() to modify URL and using mod_rewrite and a PHP back-end that can serve a default content template in the case of a direct request like "mysite.com/about" (mysite.com/index.php?page=about) (for basic useabilty and SEO), i cannot also set meta content for direct requests unless i have two templates - a content template - and a meta template? is there another way around this?
are tags like <title> and <meta name="description"> important enough to warrant having a template especially for them?
in summary, i want my nice mod_rewrite URLS to pull up on google with the correct title and meta description for a particular ajax-loaded page content template.
EDIT
i'm going for pretty much the same thing they have going on here at hypem.com. they have an event listener which changes the <title> tag when new content is listed. they also serve the correct <meta name="description"> tag, but only if it is a direct request to one of the main pages, like blogs - other pages, like http://hypem.com/blog/indie+today/10332, return the meta tag for the main blog page, and only when directly requested
I would first build the site to work with all direct links and no ajax, and then add the ajax. However, only include the code that adds the ajax/history functionality if the page is being requested by a browser. If a web crawler hits your site, don't include the ajax/history functionality.

Test custom header in Drupal before publishing

I'm quite new to Drupal and want do some editing of the header. I want a custom toolbar to appear on every page. I've already created that toolbar in a file called toolbar.php. It has a layer which is fixed and will appear on top of every page.
How do I include the toolbar.php in the header template of drupal?
The toolbar refers to $user which is a global Drupal variable and I want to test toolbar.php before publishing it to the site. Is there anyway I can do that?
Regards,
Dasith
Of the two methods above the first is easier if you understand the basic idea of html and CMS templates, the second will be easier if you are a programmer.
First thing to check is that you really need to do this! Can't you restyle one of the existing menus (Primary or secondary) to do this - will make your life (and anyone who works on the site in the future) a lot easier.
The other thing you can do is look into adding an output region, basically something where you put the php into a drupal friendly format and then effectively do a 'drupal print'. This is how the toolbar, search box etc are done. You still need to alter the templates as above.
Yes for sure. If you want to have the html produced by your function/file appear on every page of the site then you will need to over-ride the page.tpl.php file in the theme you are using and essentually add the html to that file.
To gain access to the $user variable, just declare it in your script.
global $user;
open page.tpl.php file in a code editor and save as page-front.tpl.php (with two dashes if you are using Drupal 7.. one dash with Drupal 6) and upload it to your theme's directory. Clear your cache by going to configuration->Performance->Clear All Cache. Then referesh the page. Now your homepage is using page-front.tpl.php as it's template file. Every page will need its own template file. The page machine name comes after the hyphen so the user page template uses page-user.tpl.php. You can edit it as you want. The proper way to really do this is to use hook_theme() to pass variables to the template file. One variable could be the html which creates your custom header.
See also http://drupal.org/node/457740 Beginners Guide to over riding theme output

How do I extract the blog posts like this site did?

This site is built on Ning. You'll notice they have jQuery tabs set up on the home page and looking through the source code, you'll see that those tabs are getting their content from an outside url (below):
<div class="ui-tabs" id="tabs">
<ul>
<li>Features</li>
<li>Vip Blogs</li>
<li>All</li>
</ul>
</div>
However, those urls aren't standard to Ning (I've tried appending /vip/blog/embedPromoted?pageSize=10 on a similar Ning blog url and it didn't work) which leads me to believe that they were created separately somehow to extract just the blog posts. Here is what a blog page on Ning looks like for reference: link
Anybody have an idea of how they created these pages with just the blog posts? I originally thought of using the blog's rss feed but realized the rss doesn't include author avatars and certain post metadata information like how it is in the first link I posted above.
Any help would be hugely appreciated.
Thanks to all in advance!
The /vip URLs on that Ning site is a custom feature from when Ning used to host custom PHP code. Since it's a custom feature, it's not available on other sites.
It's possible to create something similar using the Ning API to aggregate blog content from a specific set of members into a single HTML page or RSS feed. It would have to be implemented on an external server.
Check out rssinclude.com, handy way to drop RSS feeds into a site.
If that won't work, you can use the QueryPath library to grab the HTML from the site jQuery style, but in PHP.
What do you mean by rss feeds don't include the author's avatar ? It is included in the link you have in your OP.
One way this could have been implemented is that they apply a XSLT temnplate to a RSS feed to build the HTML page .

Categories