-
AuthorPosts
-
March 18, 2016 at 1:19 pm #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 :)
March 18, 2016 at 5:50 pm #600462Hey 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,
AndyMarch 19, 2016 at 4:13 pm #600708I 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?
March 21, 2016 at 5:10 pm #601364Hey!
Thank you for coming back.
You must use the following filter:
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 -
AuthorPosts
- You must be logged in to reply to this topic.