disable comment rss - wordpress

i am using this to automatic display the rss in the header.php
automatic_feed_links();
in the header appears feed=rss2 and feed=comments-rss2
now i just want to disable the comments-rss2 since i dont use comments in the theme.
if i use remove_action( 'wp_head', 'feed_links', 2 ); both are removed from the head.
I just want to remove the comments-rss2 -
couldnt find any reference how to this.
anyone know?

feed_links function in wp-includes/general-template.php contains echo command for both feed and not be able to disable with argument. Comment out // this line: (wp-includes/general-template.php #1614 for wp3.1)
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n";

Related

Nothing happens when using register_activation_hook in Wordpress

Hiya I am trying to create a plugin in wordpress.
The aim is it will create a table in the database, however even by just adding an echo inside the hook it seems that this does not get triggered.
wp version 6.11, mysql 8.0.16, php 8.1.9
Folder structure is
wp-content
|____ plugins
|my_plugin
| index.php
To follow, this is what is inside the index.php,
I've tried also an external function, but nothing.
If the echo is outside then I can see it.
Debugging is enabled and no error are thrown.
Any ideas? Thanks
<?php
/**
Plugin Name: test tickles
*/
echo(LOG_ERR. 'Testing # ' . date('Y-m-d H:i:s') . ' ' . __FILE__ . "<br>");
echo(LOG_ERR.'WP_PLUGIN_DIR = ' . WP_PLUGIN_DIR . "<br>");
echo(LOG_ERR.'plugin base name = ' . plugin_basename(__FILE__) . "<br>");
register_activation_hook(__FILE__, function() {
echo "poo";
});
?>
To see the output of your plugin, remove LOG_ERR from your echo statements.
Your code should look like this, please try this hope it should work:
<?php
/**
Plugin Name: test tickles
*/
echo('Testing # ' . date('Y-m-d H:i:s') . ' ' . __FILE__ . "<br>");
echo('WP_PLUGIN_DIR = ' . WP_PLUGIN_DIR . "<br>");
echo('plugin base name = ' . plugin_basename(__FILE__) . "<br>");
register_activation_hook(__FILE__, function() {
echo "poo";
});
?>
It won't run on every page load - in case that's what you're expecting. It will only run when the plugin is initially activated - so to test, you will need to deactivate and then re-activate your plugin.
Also, please note that the activation hook does not work with mu-plugins.
The documentation also mentions a redirect - so you may want to try die('my plugin activated'); instead of just echo.
Relevant part of docs

Woocommerce loop title location

Building custom woocommerce template on top of storefront.
I want to replace/change some html for the individual item titles within the loop functionality for the category pages. The "add to cart" link, price, etc. are all located in woocommerce/templates/loop directory. None of the files in that directory appear contain the html for the product title for this functionality.
Where do I find this thing? I swear the most annoying thing about building on woocommerce is trying to find where all the pieces live...
woocommerce/includes/wc-template-functions.php
woocommerce_template_loop_product_title function
function woocommerce_template_loop_product_title() {
echo '<h3 class="woocommerce-loop-product__title">' . get_the_title() . '</h3>';
}
You need change the information in the file functions.php, preferably in the theme child file.
What you put there will normally be rewritten because it have priority.
Like Randy wrote it, this is a pluggable function you will find in
wp-content\plugins\woocommerce\includes\wc-template-functions.php
if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
/**
* Show the product title in the product loop. By default this is an H2.
*/
function woocommerce_template_loop_product_title() {
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h2>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
To override it, just copy paste the code without the condition in the functions.php file of your child theme and modify it according to your needs.
Ex: Change h2 for h3
function woocommerce_template_loop_product_title() {
echo '<h3 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h3>';
}

How to use wp_extract_urls() in WordPress if I want to find NOT unique links?

How to use wp_extract_urls() in WordPress if I want to find NOT unique links? I just want to count all the links in my post!
Your best bet is likely to create a new function in your functions.php file that excludes the array_unique() part of the existing function. Something like this should work -
function wp_extract_all_urls( $content ) {
preg_match_all(
"#([\"']?)("
. "(?:([\w-]+:)?//?)"
. "[^\s()<>]+"
. "[.]"
. "(?:"
. "\([\w\d]+\)|"
. "(?:"
. "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|"
. "(?:[:]\d+)?/?"
. ")+"
. ")"
. ")\\1#",
$content,
$post_links
);
$post_links = array_map( 'html_entity_decode', $post_links[2] );
return array_values( $post_links );
}

WordPress RSS list add featured image link

I want wordpress post rss list featured image link
Ex:
<title>Test title</title>
<desc>Test desc</desc>
<image>imagelink</image>
I'm not using plugin.
Thanks
This will do. Add it to functions.php file:
// add the namespace to the RSS opening element
add_action( 'rss2_ns', 'custom_prefix_add_media_namespace' );
function custom_prefix_add_media_namespace() {
echo "xmlns:media="http://search.yahoo.com/mrss/"n";
}
// add the requisite tag where a thumbnail exists
add_action( 'rss2_item', 'custom_prefix_add_media_thumbnail' );
function custom_prefix_add_media_thumbnail() {
global $post;
if( has_post_thumbnail( $post->ID )) {
$thumb_ID = get_post_thumbnail_id( $post->ID );
$details = wp_get_attachment_image_src($thumb_ID, 'thumbnail');
if( is_array($details) ) {
echo '<media:thumbnail url="' . $details[0] . '" width="' . $details[1] . '" height="' . $details[2] . '" />';
}
}
}
Also when you add this, be sure to reset the permalinks (flush them), by going to Settings > Permalinks, and either change permalinks to default, and back to your defined settings, or just re-saving.
After that, check your feed and the media should be there.

How to display associated categories with get_adjacent_post in Wordpress

I have a Next Post link at the bottom of my Wordpress article.
I am using get_adjacent_post to display the post title. I would also like to show the attached categories with my this post.
I can't find how I should write this.
My attempt is:
<?php
$prev_post = get_adjacent_post(false, '', true);
if(!empty($prev_post)) {
echo '<div class="next"><span class="link">Next article →</span><br/>' . $prev_post->post_title . '<br/><span class="grey">Filed under: ' . $prev_post->post_category . '</span></div>'; }?>
$prev_post->post_category doesn't work. Does anyone know the correct syntax?
Thanks!
get_the_category_list should do the trick:
get_the_category_list( ', ', '', $prev_post->ID )

Resources