Tag Info

New answers tagged

0

Please put below code in your functions.php file. You will need to create custom field named 'custom_post_name' and set the custom field text to what you want to add to page title. function alter_page_title(){ global $post; $current_page_title = $post->post_title; /* Check if lower case version of current page title is = online exams. */ ...


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 ...


0

This might serve as a work-around. Try changing the name of your post-type from "Portfolio" to something like "Work" or "Examples." It just needs to be a word that makes sense to you. Then change the name of your taxonomy from "Type" to "Portfolio." I think WordPress defaults to showing the relationship of the term to the taxonomy because there could be ...


0

Try this one , .. $ID = get_the_ID(); $page_data = get_page( $ID ); $excerp = strip_tags($page_data->post_excerpt); if ( !empty( $excerp ) ) : the_excerpt(); else : echo get_permalink() endif;


0

Yes, it is possible, and it is done by creating the custom taxonomy, then creating the rewrite in the custom post type, and then adding a filter for post_type_link to edit the actual permalink. Once you have the code in place, you have to go Settings > Permalinks and hit submit to refresh everything. add_action( 'init', 'register_custax_type', 0 ); function ...


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 ...


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 ...


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.


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

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

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.


0

With some help I was able to get it working with this: add_action('init', 'journal_urls'); function journal_urls() { add_rewrite_rule( '^journal/([^/]*)$', 'index.php?name=$matches[1]', 'top' ); } Maybe someone can benefit from this in the future.


0

Try adding 'source' as an custom query var, rather than defining it as a rewrite tag. function wpse162627_add_query_vars( $query_vars ){ $query_vars[] = "source"; return $vars; } add_filter( 'query_vars', 'wpse162627_add_query_vars' ); function custom_url_source() { add_rewrite_rule( '^source/([^/]*)$', ...


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); ...


0

We had the same issue, only the default permalink working with Apache mod-rewrite enabled. Other sources had us tweaking the AllowOverride in the 'Directory "var/www/html"' from 'None' to 'All', this only resulted in a 500 error when anything but the default permalink was chosen. Sometimes giving it rest and coming back to it works -- after sleeping on it ...


0

Slugs should be unique for each content type as they are a unique identifier of the content on the url side. To overcome this limitation you can simply create two costume taxonomies one for wheels and one for brakes and have a mercedes in both of them.


0

If you're using WP Category permalink plugin then disable it and use the following as your permalink custom structure /%category%/%postname%/ That's it


0

What you want and what you need is two sites with content duplication, probably under a multisite install. While you still need to write some duplication code it is a much easier to develop and debug and is low on dragons.


0

I think I found a solution to this with a function that's not commonly used: add_permastruct(). This does the trick of what I described above: add_rewrite_tag('%page%','([^/]+)', 'pagename='); add_permastruct('abc','/abc/%page%/',false); add_rewrite_rule('abc/?$','index.php?page_id=6','top'); The add_rewrite_tag() defines the pagename value that I want ...


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', ...


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. ...


0

You will have to get link like this. <?php echo home_url( '/blog' ); ?> or <?php echo home_url( '/' ) . 'blog'; ?>


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()).


0

Go to the permalinks setting in the wordpress settings page and change the permalink structure to this. https://mysite.com/%category%/%postname%/ And now add this code in your .htaccess file to achieve that permalink structure. <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond ...


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 ...


0

There's sufficient info on the web about how to get .htaccess files working with Apache2. But specifically with Vagrant, you need to ensure the required settings are implemented in Apache on your guest machine. That might be obvious to everyone else, but I wasted an changing settings on my host and couldn't figure out why it wasn't working.



Top 50 recent answers are included