I have a URL field for external links. I would like that to be the permalink, automatically if the field has a value. I can obviously check to see if this field has a value, if so, print it, else use the default url. However, I’m trying to avoid that unnecessary code. Is there another hook that I could use? Wherever the post appears, I would like its permalink to be the external URL that was provided. Thanks for any assistance!
]]>In this file https://plugins.trac.www.ads-software.com/browser/wordpress-seo/trunk/inc/sitemaps/class-post-type-sitemap-provider.php#L615 when you call get_permalink($post);
$post is not a WP_Post or and ID but your Stdclass.
In the function get_permalink() the final return has a filter :
/**
* Filters the permalink for a post.
*
* Only applies to posts with post_type of ‘post’.
*
* @since 1.5.0
*
* @param string $permalink The post’s permalink.
* @param WP_Post $post The post in question.
* @param bool $leavename Whether to keep the post name.
*/
apply_filters( ‘post_link’, $permalink, $post, $leavename );
If any plugins or custom code hook ‘post_link’ after WordPress SEO it can generate a fatal error.
Could you modify your code to put an ID or an WP_Post instance ?
Best,
]]>Somehow I’ve managed to enlarged ‘next post’ & ‘previous post’ text and now I can’t work out how to make it small again. I’ve gone through and searched for any larger than normal font-sizes but nothing has worked.
Any ideas on how to fix this?
If you scroll to the bottom of my site you’ll see what I mean https://collectivelyme.net/
Thanks,
Mardi
Events page can be found here: https://buildittogether.co/events/meetups-schedule/
I’ve rewritten the code index template to serve the eventbrite event page link on the title and for the “reserve your seat” button i added.
BUT…the featured image is still linking to what should be the single event template, but when you click on it, we’re served a 404 error.
Where should the single event template file be in the theme?
If this isn’t solved how do I change the thumbnail link to link to the eventbrite page instead of the single page template?
Thanks.
(YES, I’ve resaved permalinks)
https://www.ads-software.com/plugins/eventbrite-api/
]]>In my recent posts page, I would like the titles of the post to display the price of the item. I want that price to also be linkable to the amazon product page.
add_filter( 'the_title', 'filter_title', 10, 2 );
function filter_title( $title, $post_id, $showList )
{
if( $new_title = get_post_meta( $post_id, 'price' , true ) )
{
return $new_title;
}
return $title;
}
price
is a manually entered custom field. Instead of 'price'
I tried using 'amazon-product-show-list-price'
, but this returns a “1”, instead of an actual price. I’m assuming this means true.
I started messing with this as well. I’m new to all of this. I appreciate the help
function the_permalink( $post = 0 ) {
/**
* Filter the display of the permalink for the current post.
*
* @since 1.5.0
* @since 4.4.0 Added the <code>$post</code> parameter.
*
* @param string $permalink The permalink for the current post.
* @param int|WP_Post $post Post ID, WP_Post object, or 0. Default 0.
*/
echo esc_url( apply_filters( 'the_permalink', get_permalink( $post ), $post ) );
}
https://www.ads-software.com/plugins/amazon-product-in-a-post-plugin/
]]>home page [Works]: https://www.text.com/
taxonomy page [Works]:https://www.text.com/category/title
Normal pages [Error 404]:https://www.text.com/contact
function protocols_init() {
$protocolsargs = array(
'label' => 'label here',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'query_var' => true,
'menu_icon' => 'dashicons-admin-page',
'menu_position' => 5,
'has_archive' => true,
'taxonomies' => array('primary', 'status'),
'rewrite' => array('slug' => '%primary%'),
'supports' => array('title','editor','author','thumbnail'),
);
register_post_type('protocols', $protocolsargs );
}
add_action( 'init', 'protocols_init', 0 );
function create_protocol_taxonomies() {
$primarylabels = array(
'name' => _x( 'Categorys', 'taxonomy general name' ),
'singular_name' => _x( 'Categorys', 'taxonomy singular name' ),
'search_items' => __( 'Search Categorys' ),
'all_items' => __( 'All Categorys' ),
'menu_name' => __( 'Categorys' ),
);
$primaryargs = array(
'hierarchical' => true,
'labels' => $primarylabels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array('slug' => 'primary', 'with_front' => true)
);
register_taxonomy( 'primary', 'protocols', $primaryargs );
// Add new taxonomy
$statuslabels = array(
'name' => _x( 'Status', 'taxonomy general name' ),
'singular_name' => _x( 'Status', 'taxonomy singular name' ),
'search_items' => __( 'Search Status' ),
'all_items' => __( 'All Status' ),
'menu_name' => __( 'Status' ),
'label' => __('Status')
);
$statusargs = array(
'hierarchical' => true,
'labels' => $statuslabels,
'show_ui' => true,
'show_admin_column' => TRUE,
'query_var' => 'status',
'rewrite' => array( 'slug' => 'status' )
);
register_taxonomy( 'status', 'protocols', $statusargs );
flush_rewrite_rules();
}
add_action( 'init', 'create_protocol_taxonomies', 0 );
add_filter('post_link', 'primary_permalink', 10, 3);
add_filter('post_type_link', 'primary_permalink', 10, 3);
function primary_permalink($permalink, $post_id, $leavename) {
if (strpos($permalink, '%primary%') === FALSE) return $permalink;
// Get post
$post = get_post($post_id);
if (!$post) return $permalink;
// Get taxonomy terms
$terms = wp_get_object_terms($post->ID, 'primary');
if (!is_wp_error($terms) && !empty($terms) && is_object($terms[0])) $taxonomy_slug = $terms[0]->slug;
else $taxonomy_slug = 'not-rated';
return str_replace('%primary%', $taxonomy_slug, $permalink);
}
]]><?php next_post_link('%link', '<span data-tooltip aria-haspopup="true" class="has-tip tip-bottom" title="SHOW POST TITLE HERE"><i class="fa fa-angle-left fa-2x"></i></span>
'); ?>
thnx in advance
]]>Could someone explain me the mechanics of post_link filter and rewrite rules?
Once the permalink is modified through a post_link filter, is the updated permalink be passed through the rewrite rules again?
Considering these rules
$regex = '/dl/.*/?';
rewrite = 'index.php?pagename=dl';
add_rewrite_rule( $regex, $rewrite, 'top' );
$regex = '/(en|fr)/dl/.*/?';
rewrite = 'index.php?pagename=dl&lang=$matches[1]';
add_rewrite_rule( $regex, $rewrite, 'top' );
The URL is https://www.next.ca/dl/aa/aa/00/ri/00/?lang=fr
with a post_link filter, the updated permalink is
https://www.next.ca/fr/dl/aa/aa/00/ri/00/?lang=fr
(You will recognize Polylang’s doing)
Will the updated permalink be passed through the rewrite rules again and be caught by second rule (and index.php?pagename=dl&lang=fr be served)?
Or is it another mechanism?
Thanks in advance for your explanations.
https://www.ads-software.com/plugins/rewrite/
]]>generally SlimStat Shortcodes works fine, but I have problems to list popular pages.
Using [slimstat f=’popular’ w=’resource’ lf=’content_type equals page’ lc=’post_link,count’], I receive for example:
/content/, 24
/content/, 21
/content/, 18
i.e. it does not show the entire permalinks, it should show for example “/content/?p=563, 24”. In SlimStat Real-Time Log the links are shown correctly.
https://www.ads-software.com/plugins/wp-slimstat-shortcodes/
]]>Something like the following?
<<First <Previous – Next> Latest>>
]]>