How to get the second slug of a page url?

This problem can be solved with the WordPress Rewrite API The simplest way I assume that you’ve created a page called year and the request is most probably matched to this rule (.+?)(/[0-9]+)?/?$, with the query rewritten to pagename=year. However, you will notice from the regular expression that an additional / can be matched to … Read more

Locally change the font family [closed]

This is not really a WordPress question but I’ll answer it anyway. The first thing you need to know is CSS is your friend. You’ll want to do something like this: In style.css .serif-class {font-family: “Times”, “Times New Roman”, serif;} Then using the html view inside of your post: <span class=”serif-class”> This is an important … Read more

WordPress custom post type and taxonomy

As per Anand’s comment, something like this should work. <?php get_header();?> <?php $args = array( ‘post_type’ => ‘Video’); $loop = new WP_Query( $args ); $old_term = null; while ( $loop->have_posts() ): $loop->the_post(); $fg = get_the_terms(get_the_ID(),’category’); foreach($fg as $term): if ( $old_term === null || $old_term != $term ): $old_term = $term; ?> <h2><?php echo $term->name; … Read more

Insert the current theme header into an external HTML/XHTML file

The key to answer was found on SO; here is the solution for my case: create a PHP file with the following: <?php define(‘WP_USE_THEMES’, false); require(‘path/to/your-wordpress-dir/wp-blog-header.php’); get_header(); ?> //Contents of the body of your XHTML page go here <?php get_footer(); ?> Now you have an external page in the format of your WordPress theme.

Insert data through a script directly in the db

Yes its possible but why go over the trouble when you can use the native functions like wp_insert_post that will take care of the interaction with the database. If you are still looking to do it directly by $wpdb then the post data is saved in the posts table, the meta data for posts is … Read more

Is it possible to isolate and use WordPress functions outside of wordpress

One way to access WordPress core functionality outside of your WordPress directory is to use the following example; <?php require( ‘../path-to-your-wordpress-install/wp-load.php’ ); get_header(); // do your magic here… get_footer(); ?> However converting HTML to WordPress shouldn’t really require you to access WordPress outside of itself. Instead you want to be porting across the clients HTML … Read more

Removing Line Break Tags from a Page

You can hide <br /> elements with CSS using display:none; ofcourse you might want to try going into your post editor and removing any blank lines. WordPress converts line breaks into tags for you automatically when the content is rendered using a function like the_content().

Apply a Meta tag to one page only

You have two options. Both involve using a conditional tag. I don’t know which conditional you’ll need to test for, hence the “{something}” placeholder. (If I had to guess, you may use the is_page( $ID ) tag.) Edit your theme header file. It’s usually called header.php: if( is_{something}() ) { echo ‘<meta ……… />’; } … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)