Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #600266

    Hi,

    I’m trying to add the following piece of code before a post begins. As well as on an archive/category page. But i’m not having any luck. I used a few examples on the forums already but they outputted errors and it just wasn’t working for me, so thought i’d open a thread. Because most of the existing topics talked about adding text, where as i want to add a function.

    The code i need to insert is:

    
    // Displays the adzone anywhere the code gets added. If the adzone does not exist it will be created automatically. 
    if ( has_filter( 'wpproads_api_display_adzone' ) ){
      echo apply_filters( 'wpproads_api_display_adzone', array(
        'name' => 'Your Theme unique Adzone name',
        'description' => 'Your adzone description',
        'size' => '300x250'
      ));
    }

    I’d also like to be able to insert some code after the FIRST post on a category/archive page, could you help me with that too?

    Thank you team Enfold :)

    #600462

    Hey Transformers Universe!

    you can add your custom code inside a Code Block element. You could also search for a plugin with which you can inert custom php code.

    Best regards,
    Andy

    #600708

    I know about that, but that doesn’t help me add it to all posts at once quickly. This way it will be default and will always show before post content, if that makes sense?

    #601364

    Hey!

    Thank you for coming back.

    You must use the following filter:

    http://wordpress.stackexchange.com/questions/39918/wordpress-hooks-filters-insert-before-content-or-after-title

    The code for you must look like:

    
    function add_my_personal_text( $content ) {
       $new = '';
      if ( has_filter( 'wpproads_api_display_adzone' ) ){
      new  = apply_filters( 'wpproads_api_display_adzone', array(
        'name' => 'Your Theme unique Adzone name',
        'description' => 'Your adzone description',
        'size' => '300x250'
      ));
    
     $content =  $new. $content;
     return $content;
    }
    
    add_filter( 'the_content', 'add_my_personal_text' );
    

    Best regards,
    Günter

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