apply_filters to content NOT FROM single, or page to execute shortcodes (2 posts)

  1. tommix
    Posted 6 years ago #

    Hi, i'm using shortcodes in my wordpress, shortcodes does alot of stuff for me -it enters data to database and so on, and i DO NOT DISPLAY content, i only need to run shortcodes, so : HOW to apply_filters from external php file, not from single.php or page.php? I tried to get post ID then by using query get post's content and then apply filters to execute shortcodes - it's not working.

    i did like this:

    function apdirbam_irasa($id){
    	if (!empty($id)){
    	global $wpdb,$post;
    	$rez = $wpdb->get_row($wpdb->prepare("SELECT post_content FROM _posts WHERE id='%d'", $id), ARRAY_A);
    	$turinys = $rez["post_content"];
    	apply_filters('the_content', $turinys);

    The reason why it's not working-because of shorcode uses $id = $post->ID; to get post id and then by it runs shorcode, cause i'm calling it not from the loop so it doesn't know the ID so it's not working...how can i simulate apply_filters to run from post loop but not in single or page.php

  2. tommix
    Posted 6 years ago #

    ok i found solution:

    query_posts("p=".$_POST['id']);  if(have_posts()) {

    had to do this first and then i can manipulate post, apply tags and so on.

Topic Closed

This topic has been closed to new replies.

About this Topic