• Is this possible? For example, only make the button appear in posts using the review category? Thanks

    • This topic was modified 6 years, 1 month ago by danniee.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Alimir

    (@alimir)

    @danniee

    Yes. This is a custom case and you should place our custom function in your php templates instead of auto display mode.

    Thread Starter danniee

    (@danniee)

    @alimir I’m very happy that you responded! I’m a bit confused however as to what you mean exactly. Do you mean I need to use the shortcode? I would prefer not to do that because I would have to go back and add it to 100+ posts and also, if I one day decide to remove the plugin, the shortcode will still be there.

    I was hoping there would be a chance to choose a category in the settings but I guess that is not possible? Thank you.

    Plugin Author Alimir

    (@alimir)

    @danniee You do not need to use shortcode with this way. For example, go to the single.php file in your theme root and place the following code in the content loop:

    if( has_category( 'review') && function_exists('wp_ulike') ){
        wp_ulike('get');
    }
    Thread Starter danniee

    (@danniee)

    @alimir I very much appreciate your help but unfortunately my php skills are not as good as they should be.

    My theme single.php file looks like this:

    
    <?php get_header(); ?>
    <div class="mh-wrapper clearfix">
    	<div class="mh-main clearfix">
    		<div id="main-content" class="mh-content" role="main" itemprop="mainContentOfPage"><?php
    			while (have_posts()) : the_post();
    				mh_before_post_content();
    				get_template_part('content', 'single');
    				mh_after_post_content();
    				comments_template();
    			endwhile; ?>
    		</div>
    		<?php get_sidebar(); ?>
    	</div>
        <?php mh_magazine_second_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

    Where should I place the code? Please keep in mind I ONLY want to display the button in posts that are in the REVIEW CATEGORY, no other posts.

    Also, if I want to add this to the child theme so it isn’t removed when you update the plugin, how would I go about doing so? I supposed I need to add the code to the functions.php in my child theme folder?

    Sorry for the trouble, your plugin is really improving my site and means a lot.

    Plugin Author Alimir

    (@alimir)

    @danniee could you give me an admin access? I’ll fix it for you.
    my mail : alimir71[at]yahoo

    Thread Starter danniee

    (@danniee)

    @alimir I do this for my job and I’m not allowed to give admin access :/ I feel very bad about this because I know you want to help.

    Is this something you might consider adding for future updates? Like a checkbox in the admin settings “only display button in posts in the following category”

    Plugin Author Alimir

    (@alimir)

    @danniee No problem, I understand the situation. We consider this as a very general option in plugin setting and these are usually done by custom php coding.
    Now check for the content-single.php file for that purpose, or try this on mh_after_post_content function.

    Thread Starter danniee

    (@danniee)

    @alimir I am not getting it to work ??

    My content-single-php

    <?php /* Default template for displaying post content */
    $mh_magazine_options = mh_magazine_theme_options(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header clearfix"><?php
    		the_title('<h1 class="entry-title">', '</h1>');
    		mh_post_header(); ?>
    	</header>
    	<?php dynamic_sidebar('mh-posts-1'); ?>
    	<div class="entry-content clearfix"><?php
    		mh_post_content_top();
    		the_content();
    		mh_post_content_bottom(); ?>
    	</div><?php
    	if ($mh_magazine_options['tags'] === 'enable') {
    		the_tags('<div class="entry-tags clearfix"><i class="fa fa-tag"></i><ul><li>','</li><li>','</li></ul></div>');
    	}
    	dynamic_sidebar('mh-posts-2'); ?>
    </article>

    I’m not good with php so I would need very specifik instructions, but understand if you don’t have time for this.

    Plugin Author Alimir

    (@alimir)

    @danniee Try this one: ??

    <?php /* Default template for displaying post content */
    $mh_magazine_options = mh_magazine_theme_options(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<header class="entry-header clearfix"><?php
    		the_title('<h1 class="entry-title">', '</h1>');
    		mh_post_header(); ?>
    	</header>
    	<?php dynamic_sidebar('mh-posts-1'); ?>
    	<div class="entry-content clearfix"><?php
    		mh_post_content_top();
    		the_content();
    		if( has_category( 'review') && function_exists('wp_ulike') ){
    		    wp_ulike('get');
    		}
    		mh_post_content_bottom(); ?>
    	</div><?php
    	if ($mh_magazine_options['tags'] === 'enable') {
    		the_tags('<div class="entry-tags clearfix"><i class="fa fa-tag"></i><ul><li>','</li><li>','</li></ul></div>');
    	}
    	dynamic_sidebar('mh-posts-2'); ?>
    </article>
    Thread Starter danniee

    (@danniee)

    Doesn’t seem to work for me. I still see the button on other posts that don’t use the ‘review’ category :/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Make button only appear in specific post category’ is closed to new replies.