WordPress.org

Ready to get started?Download WordPress

Forums

Twenty Eleven
add content under post on main page (13 posts)

  1. filip_winiewicz
    Member
    Posted 1 year ago #

    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

  2. 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.

  3. filip_winiewicz
    Member
    Posted 1 year ago #

    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

  4. 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?

  5. filip_winiewicz
    Member
    Posted 1 year ago #

    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);

  6. 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.

  7. filip_winiewicz
    Member
    Posted 1 year ago #

    Yes, thats what I want. Thank you :)

  8. filip_winiewicz
    Member
    Posted 1 year ago #

    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"
    thanks

  9. Looking at the plugin http://wordpress.org/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 http://your-wordpress-url-here/ and not http://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 called Add JiaThis to the home page too.

    http://pastebin.com/0jb3ueFw

    <?php
    /*
    Plugin Name: Add JiaThis to the home page too
    Version: 0.1
    From http://wordpress.org/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() and is_page() check. I've replaced it with is_home().

    This way the plugin adds the filter to the_content for only when is_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.

  10. filip_winiewicz
    Member
    Posted 1 year ago #

    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.

  11. filip_winiewicz
    Member
    Posted 1 year ago #

    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:

  12. filip_winiewicz
    Member
    Posted 1 year ago #

    <a href="http://www.jiathis.com/help/html/add-more-icons/">如何在一个页面中添加多组分享代码</a>
    <!--本页第一个分享工具代码开始-->
    <div onmouseover="setShare('如何在一个页面中添加多组分享代码', 'http://www.jiathis.com/help/html/add-more-icons/');"> <!--自定义第一个分享标题和链接-->
                         <!-- JiaThis Button BEGIN -->
                         <div class="jiathis_style">
                         <a href="http://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="http://www.jiathis.com/news/html/jiathis-wordpress-plugin">JiaThis发布最新WordPress分享插件</a>
    <!--本页第二个分享工具代码开始-->
    <div onmouseover="setShare('JiaThis发布最新WordPress分享插件', 'http://www.jiathis.com/news/html/jiathis-wordpress-plugin');">  <!--自定义第二个分享标题和链接-->
                            <!-- JiaThis Button BEGIN -->
                            <div class="jiathis_style">
                            <a href="http://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="http://v1.jiathis.com/code/jia.js?uid=您的UID" charset="utf-8"></script>
    <!--分享功能代码结束-->
  13. filip_winiewicz
    Member
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags

No tags yet.