2010-07-17 session questions


Updated 2010-07-22: revised
Using get_permalink for links in posts and
pages
.


The session today is a workshop in which several of our
members will answer one on one questions specific to each person’s blog and,
hopefully, resolve issues and problems on the spot.


Here are mine:


Using get_permalink for links in posts and pages


I am looking for a way to use links from one post or page to
another within my blog that will work regardless of changes I make to its
permalink structure and not depend on rewrite rules other than the builtin ones
to resolve. The following excerpt from
Create Links to Posts and Category explains the issue:



We all know that it is good to have links posts and
categories throughout you site, but maintaining hard coded links can be a pain,
especially when things like permalink structure or domain name change. These
two functions will allow you to create flexible dynamic links in your posts or
pages.


So you have a blog with hundreds of posts each of them
interlinked. Then you decide to change your domain name, permalink structure or
something else and you have to update all the posts again. Why not update them
with a dynamic link and let WordPress generate the URL for
you?


Is the hack provided in the post cited a way to accomplish
this?


How To Display WordPress Permalinks Outside of the Loop
provides the following code to display permalinks outside the loop:


<!– external permalink via post ID –>
<a href=”<?php echo get_permalink(33); ?>” >Permalink</a>


<!– external permalink via global $post variable –>
<a href=”<?php echo get_permalink($post->ID); ?>” >Permalink</a>


The functions in
Create Links to Posts and Category (Tim
Trott
, 2009-01-24) appears to do the same thing but the author notes
that to work inside posts and pages as opposed to a theme template, a plugin
such as
Exec-PHP is required.


Automagically adding a class selector to external links


The
Identify
External Links
plugin searches the text for links outside of the domain of
the blog. To these, it adds class=”extlink” (and optionally,
target=”_blank”). Source:
WordPress CSS link styler.


I would like to this plugin so that if an external link
already has a class or compound classes specified, then it add
extlink to it.


Include a file external to blog in post


In a post tab, I want to include a file/page from a server
directory outside WP which I plan to use for my
internal page from which the post was created. In addition, I want the tabs to
appear only if the user is admin or a named user.


I found the following techniques from
WordPress include external file:



  1. Using
    the WordPress Shortcode API to include an external file in the post content

    and WP
    Include File: a WordPress Plugin
    ;

  2. Embed
    External Content via iframe and div
    ;

  3. External Files;
  4. Including
    External Files in a WordPress Post using PHP Execution

  5. Dynamic
    Loading of External HTML file Using Jquery

  6. Include
    Me In That HTML ~ Plugin
    and Include Me In That
    (html) Plugin
    [same blog]


How to implement Tarski theme loop.php change


In a thread in the Tarski forum,
Plugins: Front-end Editor (scribu) plugin: use of
the_title_attribute() instead of the_title()
, the theme developer changed a
theme file, loop.php, to use the_title_attribute but didn’t say how to implement this
change.


I’m not sure how the Git repository
works and whether I can simply obtain a copy of the new version of
loop.php and replace the current version with it.

Remove category base and use text string


The
WP No Category
Base
(iDope) plugin removes the permalink’s
category base. I want to use the permalink structure /%category%/%postname%/ and a text prefix to avoid the performance issue; i.e., topics/%category%/%postname%/.


Does this technique avoid the problem discussed in
Category in Permalinks Considered Harmful (2010-04-09)?

See my
comment in that post
asking if the technique I set out there would work. I haven’t had an answer
from the post author (yet).


Resources:



  1. WordPress:
    Custom URL rewrite and reading URL values
    (Learning Is Fun).

  2. Pathless Category Links:

    1. Pathless
      Category Links

    2. WordPress
      and “Pathless Categories”

    3. How
      to: Remove /category/ from your WordPress url
      .


1 Comment

  1. Edward Caissie on 2010-07-25 at 12:33

    Q: How to implement Tarski theme loop.php change …
    I just looked for a more recent version of Tarski than 2.6 and was unable to locate. It is not in their public repository (GIT) nor has one been released to WordPress for review … but, if you follow the discussion you(?) started on their forums it presents a link to the changes they will be adding.
    The edit to the theme is very straight forward and should not affect anything else at a glance.