Tag Info

Hot answers tagged

9

You can get the value of front in the global $wp_rewrite: global $wp_rewrite; echo $wp_rewrite->front; // or echo home_url( $wp_rewrite->front ); Though that is probably of limited use, as the front base isn't necessarily an existing page, and may 404 in many cases. If you're using that value to prepend to other URLs, you're likely doing it wrong. ...


4

You have totally missed the naming convention when coming to the taxonomy archive pages, and most probably the same goes for your archive pages for your custom post types Here is how your taxonomy archive pages should look like taxonomy-{taxonomy}-{term}.php - If the taxonomy were sometax, and taxonomy's term were someterm WordPress would look for ...


3

I was about to suggest something like the function bellow, but lets face it @Milo's answer is just a bit smarter, so just for completeness reason and because I already wrote it down. function wpse163163_site_url_with_fix_permalink_base() { return get_site_url() . '/' . preg_replace( '/\%([a-z0-9]+?)\%/i', ...


2

Assuming your custom taxonomy is called artist (and you don't override the slug in the rewrite parameter) you can use the rewrite tag %artist%. WordPress implements almost every functionality to use those rewrite tags in post permalinks. There are only a few small adaptations necessary. Building the Permalink First, you'll need to use the post_link filter ...


2

The href attribute you are passing under the_post_thumbnail() is incorrect. Note that this attribute is applied to the img tag which obviously doesn't supports href attribute. It would be better to wrap the_post_thumbnail() with an <a> tag. So it will look something like the following: echo '<a href="' . get_permalink( $thumbnail->ID ) . ...


1

I can't say I've ever tried including wp-load.php directly, but I've had success using: define("WP_USE_THEMES", false); include("wp-blog-header.php"); ... when trying to invoke Wordpress stack in a non-templated workflow. wp_blog_header.php does make the call out to wp-load.php but also wires up some other stuff (such as calling wp()).


1

Try this query, remembering to change out your_posts_table with the proper name in your database. Using CONCAT, you can add any number of strings, just pass post_name to add your changes before/after. update your_posts_table set post_name = CONCAT('pre-', post_name) More info on MySQL CONCAT Note: Use a WHERE clause if you only want to update specific ...


1

WordPress uses the attachment filename to create the attachment post slug. If your file was named something else, there would not be any conflicts. If you have your post permalinks set to /%postname%/ , and you upload an image FIRST, and then create a post SECOND, then WordPress has to make a choice between the two when someone tries to access the ...


1

I've done something similar to what you are after here, but I was simply filtering by a meta key. add_action('init', 'add_custom_meta_url'); function add_custom_meta_url() { global $wp,$wp_rewrite; $wp->add_query_var('food'); $wp_rewrite->add_rule('food/([^/]+)','index.php?food=$matches[1]','top'); $wp_rewrite->flush_rules(false); ...


1

WordPress uses sanitize_title to create the URL-friendly version of titles for use as post slugs, which has sanitize_title_with_dashes hooked to the sanitize_title filter. You can see sanitize_title in use in source for wp_insert_post here, and sanitize_title_with_dashes in source here.


1

I would really suggest using one custom post type and one custom taxonomy with terms under the custom taxonomy which is assigned to a show. This structure will function exactly like normal posts with normal categories, the only difference is that it will be outside the scope of default blogging as custom post types are excluded from the main query. There ...


1

You can get attachment URL like this. <?php if ( have_posts() ) : while (have_posts()) : the_post(); ?> <a href="<?php $featured_image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); echo $featured_image_url[0]; ?>"> <?php the_title(); ?> </a> <?php endwhile; endif; ?> ...


1

It is because of 'has_archive' => true which instruct wordpress to look for an archive template for the CPT. If you have a page with the same slug (portfolio) it will never get to display it as everything gets priority over pages.



Only top voted, non community-wiki answers of a minimum length are eligible