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
Related
I have a Wordpress website, now i want to change the post template name how it displays in the Wordpress CMS. Now it's saying "Standard template", i want to rename this to "News", just for usability reasons.
I can't find a way to do this. I know you can create new post templates by creating new files, but it always takes the single.php as standard template. I'm also using a child-theme, so i dont want to delete the single.php file, just rename the text: "Standard template".
Thanks in advance.
I tried creating a new post template file with a custom title. This doesnt solve problem, as the single.php file will still be the standard one (i dont want the user to have to change the template).
You can use another single.php for another post type for example if you have news registered as a post type you could have a single-news.php and that file then would server all the single views of postype = news. But from what i understand you would like to create a template appearing to the user with a different name. For that the best practice is to create a directory inside your child theme and name it page-teplates. Inside this directory you can create as many different templates you want and wordpress will recognize them but adding the following code at the top of each template. For the sake of the example lets say i want to create a contact page template. I will create a contact.php file inside the directory page-templates and have these lines of code inside.
<?php
/**
* Template Name: Contact
**/
get_header();
/* My templates Code/Design Here */
get_footer();
The possibilities are endless.
The code in this post will generate a dropdown box similar to the one that you see in pages.
All it requires is a little editing of your child themes functions.php file .
In most cases, you just need to copy your single.php file to a new file name in your child theme and edit the functions.php file in your child theme. Name your templates as seen in the code Dimitrios posted.
consider using the premium elementor page builder to create custom post templates that you can apply at will.
Try a plugin like Post Custom Templates Lite
I want to ask that can I create a file with my favorite name and use WordPress Codex in it ? How I can do that ? I want to load posts of a unique category in it ...
Note: I don't want to create a Page from WP Dashboard.
Thanks !
It will be better to create a page template and write the code for displaying post from category. Then assign your template to any of the Page in Wordpress Dashboard.
Look at the Wordpress Template Hierarchy
To load posts of a unique category (e.g. movie_cat) you can create a file named category-movie_cat.php.
Click here for a larger version of this picture
If you want to create a new php file which will work with your WordPress install, create your new file and copy/paste this piece of code, name this file like you want:
define('WP_USE_THEMES', false);
/** Loads the WordPress Environment and Template */
require ('wp-blog-header.php');
Correct the path for wp-blog-header.php according to where your new file is placed (in this example, the file is at the same level of wp-blog-header.php).
Add your special script to this page and you're done !
Note that this method is a way to display your content in another way than the activated theme. If you want to add function in your plugin or theme, you only need to include it in your functions.php or main plugin file to use WordPress functions, db...
Hope it helps
I need to put a youtube playlist in a href, belong the code I'm using :
here
but the link is automatically embed in my post page, what should I do to display something like that : ' here (with youtube playlist urls ):
WordPress automatically adds a filter to embed the videos. All you have to do is removing this filter with the following line (in a plugin or in the functions.php file of your theme): remove_filter('the_content', array($GLOBALS['wp_embed'], 'autoembed'), 8);.
(source)
I'm trying to render shortcodes in my WordPress 4.3 RSS feed, by adding a filter to my theme's functions.php like this:
add_filter('the_content_feed', 'do_shortcode');
add_filter('the_excerpt_rss', 'do_shortcode');
The thing is it doesn't render like it does in the web version, for example for the appbox it shows this:
instead of this, which i see in the article:
How can I make it show the same?
I'm using WordPress and I've made a number of posts. What file do I need to edit, so the same HTML shows on the bottom of all the posts?
there are so many file wordpress theme structure if you want to edit:
(i think you Edit single.php)
page.php : use for simple page
index.php : use for post page
single.php : use for single post if you want to change ur post setting
similerly footer.php, header.php
The default name of the template file used to display pages in Wordpress is named page.php. It is located in your current theme.