add content under post on main page
-
Hi, I couldn’t find a topic with answer to my problem. I have basic version of twenty eleven. I want to add a codeline with share buttons under the posts. And it has to be visible on the main page under each post. I have some plugins that will display just on the post page. Where do I have to paste the code to have it on the main page? I don’t have the child theme if it makes any difference.
Thank You
Filip
-
Which plugin are you currently using? Some have the option to display on the post, page, single, etc. depending on what and where you want to show it.
I don’t have the child theme if it makes any difference.
Only makes a difference if you’ve made changes to the Twenty Eleven files… If you have then you may lose any changes you’ve made to those theme files.
Hi Jan, thank you for fast answer. The plugins don’t have this option, those are plugins with my national sites. I have a code ready I would like to use, I just don’t know where to paste it. I got a Post rating plugin and I can see it on the main page and on the post pages. But I can’t find right share plugin that would do the same so I need to use the code I guess
The plugins don’t have this option, those are plugins with my national sites.
…
I got a Post rating plugin
The reason I asked was because most of those plugins add to the post via a filter such as
add_filter( 'the_content' , 'mh_magic_content_added' );
I made up the
magic
part by the way.;)You can modify where the filters are ran via your own plugin because those filters get queued up. It’s a plugin for a plugin and usually that works very well.
You can see an example of such a plugin at this post over here. It’s for a different plugin but the idea is the same: check where there user is and apply or remove the filter of that other plugin as needed.
Edit: There’s a lot of post rating plugins, can you provide the URL to the one that you are using?
So the “Post ratings” (thats the name) plugin has:
add_filter(‘plugin_action_links’, array($this, ‘PluginSettingsLink’), 10, 2);
and it works as I’d like the other to work. And this is the code from the one showing the buttons only on the post page:
add_filter(‘plugin_action_links_jiathis/jiathis-share.php’,’jiathisActionLinks’, 10, 2);
This is the type of problem I enjoy working on. Sadly, it’s Sunday and I’m heading out for a few hours. ??
If someone else doesn’t pick this up I’ll poke at this problem tonight. It sounds like you want that filter for the home page as well as the post page.
Yes, thats what I want. Thank you ??
Now I’ve noticed both plugins have 3 lines od add_filter code, so maybe if you wont see them you can’t help me. The sharing plugin is “jiathis”
thanksLooking at the plugin https://www.ads-software.com/extend/plugins/jiathis/ it looks like this may work.
When I say may work, I mean a) the text for the plugin is in Chinese and b) while I have gotten the icons to display I don’t know if they work or not.
I think the plugin is designed for sharing the URL that the user is on. For posts that makes sense but for a page with lots of posts then it may share the URL
https://your-wordpress-url-here/
and nothttps://your-wordpress-url-here/fantastic-post/
which is what you would want.Try saving this code to
wp-content/plugins/jiathis-home.php
and then activate the plugin in your dashboard calledAdd JiaThis to the home page too
.<?php /* Plugin Name: Add JiaThis to the home page too Version: 0.1 From https://www.ads-software.com/support/topic/add-content-under-post-on-main-page?replies=8 */ add_filter( 'the_content', 'mh_jiathis' , 20 ); function mh_jiathis($content) { $jiathis_code = get_option('jiathis_code'); $jiathis_dir = 'float:'.get_option('jiathis_dir'); $jiathis_clear = '<div style="clear:both; margin-top:5px; margin-bottom:5px;"></div>'; // if(is_single() || is_page() && get_option('jiathis_feed') == 'yes') { if( is_home() && get_option('jiathis_feed') == 'yes') { if(get_option('jiathis_pos') == 'down') { $content = $content.$jiathis_clear."<div style=\"".$jiathis_dir."\">".$jiathis_code.'</div>'.$jiathis_clear; } else if(get_option('jiathis_pos') == 'up') { $content = $jiathis_clear."<div style=\"".$jiathis_dir."\">".$jiathis_code.'</div>'.$jiathis_clear.$content; } } return $content; }
I’ve duplicated the function they’ve defined in their plugin and changed
is_single()
andis_page()
check. I’ve replaced it withis_home()
.This way the plugin adds the filter to
the_content
for only whenis_home()
is true. The other plugin handles the posts, this handles the home page.That put the icons beneath each post on your home page. Check if it works, I’m not sure those icons will share the post correctly.
Hi, thanks for your time again. I did as you wrote and the plugin is on the main page now, but it shares only the url of my main page. I have the jetpack sharing plugin installed. it’s also under each post and when i share on fb it shares the link to each post. so its fine. Maybe it would be easier if I would just add my links to sharing. I already tried that, and it didn’t work because I’m not sure how the url in sharing should look like as its not possible to check the settings for existing buttons.
I spoke with the plugin developer. I’m not sure if he understood me but he gave me this code and told me to paste it in the webpage code:
<a href="https://www.jiathis.com/help/html/add-more-icons/">如何在一个页面中添加多组分享代码</a> <!--本页第一个分享工具代码开始--> <div onmouseover="setShare('如何在一个页面中添加多组分享代码', 'https://www.jiathis.com/help/html/add-more-icons/');"> <!--自定义第一个分享标题和链接--> <!-- JiaThis Button BEGIN --> <div class="jiathis_style"> <a href="https://www.jiathis.com/share/?uid=您的UID" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享</a> <span class="jiathis_separator">|</span> <a class="jiathis_button_tsina"></a> <a class="jiathis_button_qzone"></a> <a class="jiathis_button_kaixin001"></a> <a class="jiathis_button_renren"></a> </div> <!-- JiaThis Button END --> </div> <!--本页第一个分享工具代码结束--> <br/> 第二条:<a href="https://www.jiathis.com/news/html/jiathis-wordpress-plugin">JiaThis发布最新WordPress分享插件</a> <!--本页第二个分享工具代码开始--> <div onmouseover="setShare('JiaThis发布最新WordPress分享插件', 'https://www.jiathis.com/news/html/jiathis-wordpress-plugin');"> <!--自定义第二个分享标题和链接--> <!-- JiaThis Button BEGIN --> <div class="jiathis_style"> <a href="https://www.jiathis.com/share/?uid=您的UID" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank">分享</a> <span class="jiathis_separator">|</span> <a class="jiathis_button_tsina"></a> <a class="jiathis_button_qzone"></a> <a class="jiathis_button_kaixin001"></a> <a class="jiathis_button_renren"></a> </div> <!-- JiaThis Button END --> </div> <!--本页第二个分享工具代码结束--> <!--单页面使用多分享按钮需要增加的分享参数代码--> <script type="text/javascript"> function setShare(title, url) { jiathis_config.title = title; jiathis_config.url = url; } var jiathis_config = {} </script> <!--分享参数代码结束--> <!--分享功能代码统一放到页尾--> <script type="text/javascript" src="https://v1.jiathis.com/code/jia.js?uid=您的UID" charset="utf-8"></script> <!--分享功能代码结束-->
but i thinkthese are 2 separate codes. its just from button begin to buttion end. is hould probably paste it in index.php loop, but i’m not sure where and if the effect will be as I expect
- The topic ‘add content under post on main page’ is closed to new replies.