I want to manually write my rss and use it to import posts into several blogs i have
<item>
<title>testin</title>
<description>hello</description>
<custom field????
</item>
How to add a custom field to be seen by wordpress?
Is there a free soft which i can use to write rss quicklier?
TY!
If you want WordPress to "see" it, you will have to convert your xml into structs that match what WordPress is expecting for newPage, newComment, newCategory etc... you can see the struct parameters as well as return values here...
WordPress API
Related
Is there a way to get the Podcast Name, Episode Title, and Date through a link inserted in a wordpress post?
I'm using ACF plugin where the user may insert a podcast link.
Like what happens when I paste a link in WhatsApp, and an information with appears containing even an image or a logo from the website pasted.
Thank you.
AMP.
Yes!
Option 1
You could hook into the save_post hook, get the url that has been supplied, grab the data from that url with either curl / file_get_contents / whatever and then save the data as post meta for that post.
On the frontend, you can grab the saved data from the post meta.
Option 2
You could also grab the data on the frontend. Either with php in wordpress, or on the client side with js (e.g. axios or fetch). You get the acf link and pass it to e.g. window.WP_VARS, for your clientside code to use it. I e.g. use this to pass generic vars to my clientside code:
wp_register_script('mainjs', get_template_directory_uri() . '/js/main.js', array(), REL_VERSION, true);
wp_localize_script('mainjs', 'WP_VARS', $generic_vars);
wp_enqueue_script('mainjs');
The advantage of this is that you don't have to store and grab this data from your database. Make sure that the fetch is non blocking, so do it on page ready.
I am new to WordPress development. I am coming from Symfony and vanilla PHP development.
I want to assign a "route" or a function to generate an XML file for a specific post type.
I know that I can get the post information with WordPress functions like get_post_meta.
I don't know the how to assign a function to a link
DOWNLOAD XML.
What is the "WordPress way" to do this?
Wouldn't an Ajax call do the job?
I'm a new in WP also. So I did this way:
1) I made a template myxmltemplate.php in /wp-content/themes/mytheme/myxmltemplate.php starting with:
/**
* Template Name: XML
*/
2) I created a page with template XML with url for example example.com/xml/
3) I put all my code into myxmltemplate.php which generates XML code I need
4) after that I can make a link like this
DOWNLOAD XML
Maybe there is a better way to make routes with xml-generating (like in functions, but for me it's the simplest).
I added Adsense to my content via shortcodes. But Adsense codes appears in RSS too. How can I hide shortcodes from RSS Feed and show only for in posts ?
I am using sahifa wordpress theme.
You will need to alter how the RSS is output.
All the RSS styling files are located in the wp-includes folder and are titled as follows:
feed-rss2.php
feed-rss.php
feed-rdf.php
feed-atom.php
feed-atom-comments.php
feed-rss2-comments.php
Then within these files, you need to find where it calls the function the_excerpt_rss(). This calls out the content in excerpt format.
You will need to enclose this in a function called strip_shortcodes().
As an example from feed-atom.php line 70:
<summary type="<?php html_type_rss(); ?>"><![CDATA[<?php strip_shortcodes(the_excerpt_rss()); ?>]]></summary>
Hope this helps
I wonder if I could ask a Wordpress / RSS question I could't find an answer for around here,
Trying to syndicate posts via RSS in Wordpress using the FeedWordpress plugin as an RSS aggregator, each post in the original blog includes five custom fields that are important for its Theme functionality (the original and syndicating / receiving blog using the same theme).
The original RSS2 feed doesn't include these custom fields apart from one, being enclosure, that is defined in the default rss feed template (function in WP rss_enclosure).
This is written in the original feed such as:
<enclosure url="http://www.samplevideourl.flv" length="18554755" type="video/x-flv" />
Tried to add the rest of the custom fields modifying the rss2-feed.php template so they show at the end of each segment in the current RSS2 feed, now they are included as for example:
...
<ratings_average>0</ratings_average>
<views>5</views>
</item>
However, if I update the syndicated posts, or delete the posts and fetch the modified feed again with feedwordpress, none of these show in the syndicated posts.
Is there a way to include these custom fields so they are recognized by feedwordpress?
Basically need to syndicate the same format of the post as the original including all its custom fields.
Many Thanks
Carlos
There is a thread that covers this: https://wordpress.stackexchange.com/questions/3801/add-custom-fields-to-custom-post-type-rss
I've condensed the answers there to reflect the later improvements (thanks MikeSchinkel, prettyboymp and Acts7).
Add this to your theme's functions.php:
/* IN ORDER TO VALIDATE you must add namespace */
add_action('rss2_ns', 'my_rss2_ns');
function my_rss2_ns(){
echo 'xmlns:mycustomfields="'. get_bloginfo('wpurl').'"'."\n";
}
add_action('rss2_item', 'yoursite_rss2_item');
function yoursite_rss2_item() {
if (get_post_type()=='my_custom_post_type') {
$fields = array( 'field1', 'field2', 'field3' );
$post_id = get_the_ID();
foreach($fields as $field)
if ($value = get_post_meta($post_id,$field,true))
echo "<mycustomfields:{$field}>{$value}</mycustomfields:{$field}>\n";
}
}
This will add all custom field names and values to the site's main feed.
Note, for custom fields with more than one value, a modification is necessary as the above will only work for single value fields, not arrays.
So,
On your Master site (where you are syndicating FROM) you add the above function.
On the Slave site (where you are syndicating TO), assuming you have FeedWordPress installed, go to "SYNDICATION" ->
Click on the name of the RSS feed
Go to Custom Feed Settings and plug in the pieces
Trying to modify the RSS feeds created by Views module in Drupal.
Since there are no 'theme_' hooks for the RSS feeds (rightfully as XML is theme-less), I need an alternate way to modify the fields that are output into the RSS, preferably using template.php if possible.
http://api.drupal.org/api/function/format_rss_item/6 looks promising as that is where each row is created, but it doesn't
node_feed() is what collects the nodes, creates the additional fields, and then calls format_rss_item().
Specifically, we need to remove the dc:creator element from the $extra array created in node_feed()
If you go into a specific content type, you can set the RSS display fields as per this post:
http://redfinsolutions.com/redfin-blog/show-hide-fields-views-generated-drupal-rss-feed
I am adding another answer, as I have recently had to do this and managed to do it without modifying data in the theme layer.
You can add a preprocess function to your view. It is a bit of work though.
There are some guidelines here, but they are a bit confusing. Here is my summary of how to do this.
First make sure your modules weight is > views
Secondly copy the template you would like to add a preprocessor to to your modules directory. Rename it to be something in the list of templates in theming information.
Then edit hook theme like this (but change to use the existing view that you need to override.
function mymodule_theme($existing, $type, $theme, $path) {
// Copy the exsisting views theme from the existing array.
$override = $existing['views_view_row_rss'];
// Add my preprocessor to the list of preprocess functions
$override['preprocess functions'][] = 'mymodule_myfunction';
// Point to a template so that this view will be used.
$override['template'] = 'my_more_specific_template_name';
$override['path'] = drupal_get_path('module', 'path');
unset($override['file']);
// Return your theme handler.
return array('my_more_specific_template_name' => $override);
}
You should then be able to write your preprocess code in the function mymodule_myfunction.
In the view, if you click on "style information" this will show you the template files used to create the feed. You can copy the template so that it is overridden for your view and remove dc:creator from the $item_elements array.
This is not particularly nice as you are modifying data in the theme layer, but it will do what you want.
I'd suggest using the Views Node Feed module to do this. It will let you completely write the XML that is output by Views for feeds.