Search Results for 'do_shortcode'

Results from the Forum
OverPress
Participant
#0

Hello, a question: I want to change the css only when the shortcode is active. Using this function:

add_filter('the_content', 'custom_category_text');
function custom_category_text( $content ) {
global $post;
$cats = array( 2815, 1966, 1967, 1968, 4227, 1969, 4581, 1970, 1971, 1972, 1974, 1975, ); //cat IDs for which to append content
$text = '[pro_ad_display_adzone id="171616" background="1" container="skin"]';
$post_cats = wp_get_post_categories( $post->ID );
if( in_array( $post_cats[0], $cats )) $content .= do_shortcode( $text );
return $content;
}

i entered a shortcode in some articles.

I wish this CSS was when shortcode is active:

.td-header-header {
padding-top: 200px;
}

Is possible?

Alin [tagDiv]
tagDiv Staff

Hi,

You can use do_shortcode() function in page template that you use to display a slider or a block there. Add a block using page builder and set articles to display(category, sort..) – http://screencast.com/t/IU2p24MReul change to Classic mode and take the shortcode – http://screencast.com/t/yHgk8eeDqtTf and use it bellow pagination – http://screencast.com/t/YNvQQxdrB5http://screencast.com/t/IGVuezEe

echo do_shortcode('your shortcode');

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

You can try to place your code in “Article bottom ad” so I can inspect this and try to provide you a css solution for that space.
Also if you wnat to place your ad bellow share button like in your example you can try to paste your code in a custom ad and use do_shortcode function to display it after bottom social share – http://screencast.com/t/2EynJrxz

<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]');?>

Result: http://screencast.com/t/b1AiHmv0T3

Hope this helps!

Lucian
tagDiv Staff

Hi,

You can do this by editing your post’s template files and use the do_shortcode function to place there, after the posts content any widgets you build using visual composer’s page builder. You can find more details on how to do this in this tread: https://forum.tagdiv.com/topic/implement-infinite-scroll-on-single-posts/#post-43481

Thanks

Alin [tagDiv]
tagDiv Staff

Hi,

Yes you can paste your code in a custom ad from Theme Panel and use do_shortcode function to place it where you want to be displayed in the post template: http://screencast.com/t/52UuLXpU

<?php echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]'); ?>

Result: http://screencast.com/t/xnUxbaEV7552

Thanks!

idansx
tagDiv Member

I already solved it. I made a new variable $advertisement and inserted the do_shortcode into this variable.
Then concatenated it like this $advertisement . $videoiframe
It’s the same as you said 🙂

Thank you

Lucian
tagDiv Staff

Hi,

If you put the php code between apostrophes like this: http://screencast.com/t/JuxaG3bp it will be interpreted as a string and the output it will be parsed like it is not rendering the code.

Try to concatenate the script and the rest of the html after the do_shortcode function, it should look something like this: http://screencast.com/t/au5wceeOH – while you declare a variable you don’t need to php tags anymore as you are already in php language.

If you still have issues with this and can’t manage to do it we suggest you get a freelancer to do it for you as you need custom work for this.

Thanks

idansx
tagDiv Member

Okay I succeed to insert the shortcode without receiving fatal error by adding slashes before the apostrophe signs like this:
$videoiframe = ‘<?php echo do_shortcode(\'[td_ad_box spot_id=”custom_ad_1″]\’); ?><script type=\’text/javascript\’>………

But the ad is still not shown

When I check the source code it’s shown like this: http://i.imgur.com/JdYwFzb.png

It didn’t translate the PHP code to HTML code. Why?

  • This reply was modified 11 years by idansx.
  • This reply was modified 11 years by idansx.
idansx
Participant
#0

I have a particular plugin that inserts a video iframe. I want to insert right before this iframe an advertisement, but with the theme shortcode.

Here’s the relevant line from the plugin’s code:
$videoiframe = ‘HERE I WANT TO INSERT THE SHORTCODE<script type=\’text/javascript\’> … HERE GOES SOME MORE HTML CODE…

I want to insert the following shortcode, but when I put it in the place I specified above I receive ‘fatal error’.
<?php echo do_shortcode(‘[td_ad_box spot_id=”custom_ad_1″]’); ?>

I don’t know how to insert it correctly.

Can you help?

Alin [tagDiv]
tagDiv Staff

Hi,

You try to add your code in the header.php file – http://screencast.com/t/C5aAxZQL
Also if you can paste your code in a custom ad from Theme Panel > Ads and use do_shortcode function to display it there – http://screencast.com/t/3kpHNOUIDvhttp://screencast.com/t/0vRrd9Sx5oZ

<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]');?>

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

1. Please use do_shortcode function after pagination in the archive, category and page template and display a custom ad there: http://screencast.com/t/epSdJBuFR5http://screencast.com/t/FAbXy7GEe4d
Result: http://screencast.com/t/amRJfbxy

2. The theme doesn’t have an option to display social share on page and you will need custom modification for this. Unfortunately we cannot provide any custom work for the moment as we work hard on development, updates, fixes and support so the time and resources don’t allow us to provide custom work. Also you can add likes button in pages – http://screencast.com/t/buJaJuGEomS7

3. You can add block 12 (with “Read More” button) in your page please see our demo: http://demo.tagdiv.com/newsmag/block-12/

4. Please provide your site url so I can inspect this. Also you can check this without any plugins active, leave just Visual Composer active, clear cache and see if it works.

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

Please create your tab block in a page – http://screencast.com/t/qYESfNAcj8 copy the shortcode – http://screencast.com/t/ndjZ6C9ni and use do_shortcode function to display it in the post template file(if you want to replace default comments in single – default post style) – http://screencast.com/t/ntYbQUfvP

echo do_shortcode('your shortcode')
Result: http://screencast.com/t/dnhEnM4rs

I have checked this using blocks, you can use plugins shortcode instead of block shortcode – http://screencast.com/t/IFlq3eidE

Thanks!

allthingswestcoast
tagDiv Member

Found it: td_module_single_base.php

Replaced code inside get_social_sharing_top() with:

$buffy .= ‘<div class=”ultimatesocial”>’;
$social=do_shortcode (‘[ultimatesocial networks=”total,facebook,twitter,mail” align=”left”]’);
echo $social;
$buffy .= ‘</div>’;

It works, but the div code is not outputting properly. I must be doing something wrong with syntax.

Clint

Alin [tagDiv]
tagDiv Staff

Hi,

You can paste your ad code in Theme Panel in a custom ad – http://screencast.com/t/NE1V48tS and use do_shortcode function to place it above related articles in post template: http://screencast.com/t/VIshEsfTThttp://screencast.com/t/orOb1ZmJ

<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]');?>

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

To can display a custom add in attachment pages just use the do_shortcode function where you want to display it for example: http://screencast.com/t/QqfqBgr3fcN6http://screencast.com/t/iecdnat7YI

Thanks!

David
tagDiv Member

One last question, how should this code
$adcounter++;
if (is_category() && ($adcounter == 1)) {
echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]');
}

look if I would like to use it for the loop-attachment.php, in order to get ad on attachment pages?
Thanks, Loano

Alin [tagDiv]
tagDiv Staff

Hi,

You can use do_shortcode() function in footer.php file:
*Above footer: http://screencast.com/t/5uc8KSM1http://screencast.com/t/JVKzWueK3M
*Bellow footer: http://screencast.com/t/OTGyDqD2Thttp://screencast.com/t/A8ilihetw

<?php echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]'); ?>

You can try it in child theme.

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

You have to edit loop.php file like this: http://screencast.com/t/kXKRxx26

$adcounter = 0;

$adcounter++;
        if (is_category() or is_tag()) {
            if ($adcounter == 2 or $adcounter == 4) {
                echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]');
            }
        }

Result: http://screencast.com/t/Grz40A7iV3

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

Unfortunately article top ad is part of the post content – http://screencast.com/t/ajp7ZULD2lhp so the best way is to use do_shortcode function to display a custom ad in the post template(off course paste the code from top ad in a custom one) – http://screencast.com/t/KEgFONpnhdWNhttp://screencast.com/t/4IENuH9nx

<?php echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]'); ?>

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

Yes, you can use do_shortcode function and add a custom ad bellow pagination in template that you want:
Homepage with articles list – http://screencast.com/t/d9HPJK5j0http://screencast.com/t/vnljqeHfD
Category page – http://screencast.com/t/Sx5IWqWbdyhttp://screencast.com/t/IWlGaGdH
Tag page – http://screencast.com/t/oyUmCoCcDmw

echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]');

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

You can use header style 1 and alter this file and use a custom ad above logo – http://screencast.com/t/reDvpq9o6

div class="span4 td-header-style-1">
         <?php
      // show the header ad spot
             echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]');
         ?>
</div>

Also you need to change header ad to span4 – http://screencast.com/t/u33Ty5eZr
You may also need some css customization – http://screencast.com/t/W7MXCZYxkN

.td-header-style-1 .td-a-rec-id-custom_ad_1 {
margin-bottom: 0px;
}
.td-header-style-1 .td-a-rec-id-header {
top: 0px;
}

Thanks!

Alin [tagDiv]
tagDiv Staff

Hi,

Please follow this topic to add more custom ads – https://forum.tagdiv.com/topic/sidebar-ads/#post-21850
If you want to use do_shortcode() function just paste this instead using ad script there:

<?php echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]'); ?>

Just the number of custom ad that you want to display.

Thanks!

paulberrow
tagDiv Member

Thank you!
It works, but partly. As i found out the thing is i use ads which have to have kind of unic id so one ad can’t be shown on the same page more then 1 time. So i had to add 3 scripts in the custom ad fields in theme panel and i’m run out of free fields now:)

Is there any way i can add more than 3 custom ads?

About ads in category between description and posts i still can’t figure out how to do it with do_shortcode() function… Could you please provide a bit more information?

For now i just added my ad script in file category.php after this
default:
echo td_page_generator::wrap_start();
?>
<div class=”span8 column_container”>
<?php
//load the author box located in – parts/page-category-slider.php – can be overwritten by the child theme
locate_template(‘parts/page-category-slider.php’, true);
?>
It shows up in the place i need, but i’m not sure if it’s right to do it this way..

Thank you in advance!

eballi
Participant
#0

hi there,

i need one news ticker on my website. i can try this code <?php do_shortcode('[t4b_ticker]'); ?> (i tried more codes) in td_page_generator.php (line 18) . But when i try any code in this position, website give whitepage problem.

Thanks…

paulberrow
tagDiv Member

Lucian, did i get you right that if i need to show the ad after each post i have to duplicate part of the code and change adcounter? Like this

if (is_category() && ($adcounter == 1)) {
echo do_shortcode(‘[td_ad_box spot_id=”custom_ad_1″]’);
}
if (is_category() && ($adcounter == 2)) {
echo do_shortcode(‘[td_ad_box spot_id=”custom_ad_1″]’);
}
if (is_category() && ($adcounter == 3)) {
echo do_shortcode(‘[td_ad_box spot_id=”custom_ad_1″]’);
}

UPD. It doesn’t work like this so how can i show it after each post?

Viewing 25 results - 876 through 900 (of 1,077 total)