Skip to content

Instantly share code, notes, and snippets.

View q2amarket's full-sized avatar

Q2A Market q2amarket

View GitHub Profile
@q2amarket
q2amarket / README.md
Last active February 14, 2018 06:16
This code will allows to create custom page without creating a page in admin > page area. This will create automatically and doesn't require any page creation in plugin section too. Replace your-page to what you like

#Create Page With Plugin

This code will allows you to create page without adding page in Admin > Pages area. This page can be set as a home page by defining constant path in qa-config.php. Also you can create menu link by adding page request (page slug e.g. your-page).

##Usage

  • Create directory in qa-plugin. for example: your-site/qa-plugin/your-page
  • Place qa-plugin.php and your-page.php file in your-page directory you created in above step

###Optional To make page as a home page

@q2amarket
q2amarket / q2am-question-excerpt.php
Last active July 26, 2018 14:41
Question2Answer: Get excerpt of the question to display on the question list. Make sure your q2a function should get post id in array otherwise this code won't work.
<?php
$pid = $q_item['raw']['postid'];
$query = qa_db_query_sub("SELECT postid, content, format FROM ^posts WHERE postid = $pid");
$cont = qa_db_read_one_assoc($query);
$blockwordspreg = qa_get_block_words_preg();
$text=qa_viewer_text($cont['content'], $cont['format'], array('blockwordspreg' => $blockwordspreg));
$text=qa_shorten_string_line(qa_html($text), 200); //200 is the length