Skip to content

Instantly share code, notes, and snippets.

@atultiwari
Created November 28, 2017 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atultiwari/2f0a877e9e63c0c4ed334ecf50189308 to your computer and use it in GitHub Desktop.
Save atultiwari/2f0a877e9e63c0c4ed334ecf50189308 to your computer and use it in GitHub Desktop.
<?php
get_header();
?>
<div class="container">
<div class="row">
<div id="content" class="main-content-inner col-sm-12<?php echo ' col-md-12' ?>">
<article id="template" class="template page type-page status-publish hentry">
<header>
<h1 class="page-title" align="center">Page Title
</h1>
</header>
<!-- .entry-header -->
<hr>
<div class="entry-content">
<div class="entry-content-thumbnail">
</div>
<?php
$form = anspress()->get_form( 'question' );
$values = array(
'post_title' => 'Question title goes here, just make it little longer',
'post_content' => 'Question description goes here, just make it little longer, more longer, more more more longer',
'is_private' => false, // True if not private.
'category' => 5, // Id of taxonomy term.
'tags' => array(
26 => 'aiims',
33 => 'anatomy',
29 => 'nimhans',
), // question_tag taxonomy term in id=>name format.
)
$form->set_values( $values );
$post_id = AP_Form_Hooks::submit_question_form( true );
// Make sure post is inserted.
if ( ! is_wp_error( $post_id ) ) {
$form = anspress()->get_form( 'question' );
$values = $form->get_values();
$qameta = array(
'last_updated' => current_time( 'mysql' ), // When last question was active.
'answers' => ap_count_published_answers( $post_id ), // numbers of answers.
'anonymous_name' => sanitize_text_field( $values['anonymous_name']['value'] ), // Anonymous user name.
'selected' => false, // Answer id if have a selected answer.
'views' => 10000, // Numbers of views.
'closed' => false, // Is question closed?
'comments' => 10, // Numbers of comments.
'featured' => false, // is featured?
'votes_up' => 5, // Numbers of vote up.
'votes_down' => 0, // Numbers of vote down.
'subscribers' => 10, // Numbers of subscribers.
'flags' => 0, // Numbers of flags.
);
}
echo get_permalink($post_id);
?>
</div>
<!-- .entry-content -->
</article>
</div><!-- close .*-inner (main-content or sidebar, depending if sidebar is used) -->
</div><!-- close .row -->
</div><!-- close .container -->
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment