A bit of php help

Posted in: Newspaper
Post count: 111

Hey guys,

I’m trying to get the facebook like button on my pages using VC shortcode. I want to get the button under the title of my page and above the content, except on the home page. I’m just dipping my toes in editing templates, so I could use a bit of help. When I edit the page.php file, I ONLY get the like box on the home page but nowhere else.

if (have_posts()) { ?>
<?php while ( have_posts() ) : the_post(); ?>

<div class="td-main-content-wrap td-main-page-wrap">
<div class="td-container">
<?php echo do_shortcode('[vc_row][vc_column][vc_facebook][/vc_column][/vc_row]'); ?>
<?php the_content(); ?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
?>
<div class="td-container">
<div class="td-pb-row">
<div class="td-pb-span12">
<?php comments_template('', true); ?>
</div>
</div>
</div>
<?php
}
?>

I would guess it is because of the (have_posts) part. How do I get the button to display only on the pages that do not have posts? I hope you can give me some tips. It would be of great help. Thanks!

Post count: 22421

Hi,
If you want to edit the page templates and add custom code you will have to ediut one of the 3 page templates available in our theme: https://www.screencast.com/t/F9o0v4Fx01 each one corresponding to one of the 3 page templates available: https://forum.tagdiv.com/page-templates-2/
When editing a template, the code will only affect pages that use that particular template
Thank you!

Post count: 111

Hey Bogdan,

Thank you, that helped. One more question I hope you can help me with. I want the same set of share buttons above my pages as i have above the posts. I found this line of code in loop-single8.php that calls for them:

<?php echo $td_mod_single->get_social_sharing_top();?>

How do I integrate this into my page-pagebuilder-title.php? I already managed to add a Facebook share, but I would also like to call this whole set of share buttons. I tried several things, but my content just dissapears whatever I try, so I’m doing something wrong. What would be the right code to add?

Code now:

<?php while ( have_posts() ) : the_post(); ?>

<div class="td-main-content-wrap td-main-page-wrap">
<div class="td-container tdc-content-wrap">
<div class="td-page-header td-container">
<div class="td-crumb-container">
<?php echo td_page_generator::get_page_breadcrumbs(get_the_title()); ?>
</div>
<h1 class="entry-title td-page-title">
<span><?php the_title() ?></span>
</h1>
<?php echo do_shortcode('[vc_row][vc_column][vc_facebook][/vc_column][/vc_row]'); ?>
</div>
<?php the_content(); ?>
</div>
<?php
if($td_enable_or_disable_page_comments == 'show_comments') {
?>
<div class="td-container">
<div class="td-pb-row">
<div class="td-pb-span12">
<?php comments_template('', true); ?>
</div>
</div>
</div>
<?php
}
?>

Post count: 22421

Hi,

The social sharing buttons are created here: https://www.screencast.com/t/pfjiriXHb but we have not tested them on pages though. We created them for posts. I’m not sure they will work. On pages you have the page builder to help with any share option as you can get a share button from each network’s api and then paste that in a raw html element in visual composer. You do not need to edit the theme code to get a few sharing buttons on pages.

Thank you!

Post count: 19

Hello
i used the visual composer to add to pages but that before i disabled it and using td composer instead.
but in td composer there is no option to add sharing to pages .
using plugin is not logic since we have the code already running for posts .
so may be a small tip from you guys to the direction that we should do in order to have a sharing on pages also would be helpful.

Thanks you

Post count: 22421

Sorry but for pages we have not tested any sharing options.
How did you add sharing to your page in visual composer?

Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic.