Exporting WordPress Suppliers (Custom Post Type) To PDF

Wondering if someone can give me some advice on how this can be done.

So we’re working with a website that hosts a large directory of suppliers (using the Citybook WP theme).

What I’m looking for is a way in which this list of suppliers (including logo, description, etc) can be automatically exported (i.e. if a new supplier is posted, then it will auto fill into the file) to a pdf file which users can download.

I have found some very basic plugins which can do similar, but nothing that I can customize with the desired fields.

Any help or advice is much appreciated!



Custom Theming Bootsrap Carousel with Paragraph Type

Background Info:

I tried to create a custom theme for my carousel section and I am unable to get it to work. I have tried using the default carousel that Drupal comes with. I have tried using slide show views. Also I already know about Jim Bir’s Custom Bootstrap Carousel and Slick Carousel but I am unable to use them since these extensions are still in Beta.

Problem Statement:

The main avenue that I want to try to do is create a paragraph type called Carousel Section that has a reference to another paragraph type called `Caraousel Slide’.

I wanted to use this design so that way I can organize the slides individually on my pages.

Within the Carousel Slide paragraph type it would have the following fields:

  1. Slide Image
  2. Slide Title
  3. Slide Description
  4. Slide Link(which is the location of where the slide will take you if you click on it.)

I would like to use a preprocessor hook do get grab these values from Drupal and display them in my twigg file.


How can I achieve my problem statement? The bare minimal knowledge that I need is to how to at least get these fields to present themselves on my twig file and from there I can use HTML and CSS to make the carousel.

Admin Area Custom Type Search By Meta Fields Without Title & Content

I have a custom post type that uses several meta fields. In the admin area I would like to be able to search by those meta fields. I have implemented this currently in my functions.php with this code:

function custom_search_query( $query ) {
  if ( is_admin() && is_main_query() && $query->is_search ) {
    $query->set('meta_query', array(
      "relation" => "OR",
        'key' => 'first_name',
        'value' => $query->query_vars['s'],
        'compare' => 'LIKE'
        'key' => 'last_name',
        'value' => $query->query_vars['s'],
        'compare' => 'LIKE'
        'key' => 'email',
        'value' => $query->query_vars['s'],
        'compare' => 'LIKE'
    $query->set('post_type', 'application'); // optional
add_filter( 'pre_get_posts', 'custom_search_query');

The problem is that with those code if I search for say the name “walker” and I have records of my custom post type that match that criteria in the meta field I get back no results. The reason this appears to be happening is that the SQL that is being generated by the query that gets executed is this:

INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
INNER JOIN wp_postmeta AS mt1 ON (wp_posts.ID = mt1.post_id)
INNER JOIN wp_postmeta AS mt2 ON (wp_posts.ID = mt2.post_id) WHERE 1=1
AND (((wp_posts.post_title LIKE '%walker%') OR (wp_posts.post_content LIKE  '%walker%'))) 
AND wp_posts.post_type = 'application' AND (wp_posts.post_status =  'publish' 
OR wp_posts.post_status = 'future' OR wp_posts.post_status = 'draft' 
OR wp_posts.post_status = 'pending' OR wp_posts.post_status = 'private')
AND ((wp_postmeta.meta_key = 'first_name' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE  '%walker%')
OR (mt1.meta_key = 'last_name' AND CAST(mt1.meta_value AS CHAR) LIKE '%walker%')
OR (mt2.meta_key = 'email' AND CAST(mt2.meta_value AS CHAR) LIKE '%walker%') )   
GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0, 20

The query is attempting to search both the post title and content AND my custom fields. I don’t want it to be looking for matches in the title or content. How can I get the query to stop doing that and thereby returning the restuls that aI want?

magento 2 custom api return in json without response tag

I have created a custom api following “inchoo” tutorial. But I am getting the data in string format instead of json.

From my browser I am getting a tag surrounding the api return as below.
enter image description here
But Chrome’s postman extension showing a double quote (“”) and some extra slashes () in the in the response even after header to “Accept”:”application/json” and “Content-Type”:”application/json”.
enter image description here
I just want to receive the exact same string I am returning in my Model class.

 public function name() {
    //return "Hello, raihanruhin";
    $arr = '[{"name":"MasterCard"},{"name":"VISA"}, {"name":"DBBL-NEXUS"}, {"name":"American Express"}]';
    return $arr;

How can I easily make custom dungeon tiles?

I’ve gotten more mileage out of dungeon tiles than most other ways of making maps — however, I would like more variety than WOTC has put out. (In particular, I would like some curved corridors.)

I can find PDFs with tile images, so I’m really asking more about the mechanics of crafting them: What kind of cardboard? What thickness would match the stock tiles? How does one affix the printed image in a reasonably easy but secure way?

I’ve looked around a little but not seen a good site detailing the process, so I thought I’d ask here.

I’m not super-crafty, so I’d favor easy and serviceable over hard but beautiful.

M2 Get all CMS pages with custom layout

I have created a custom page template with the id tools which is a 2 column right layout.


I have created ListTools::getPages() to get the pages from the database in my sidebar module but I am not sure what to inject into my construct method and the simplest way to query the CMS pages.

Here is my code for the block:


use MagentoFrameworkViewElementTemplate;

class ListTools extends MagentoFrameworkViewElementTemplate
    public function __construct()
        parent::__construct($context, $data);
        $this->scopeConfig = $scopeConfig;

    public function getPages()
        $pages = [];
        return $pages;

I want to associate File With Custom Object but getting Error

I am trying to create new File through ContentVersion and Associating it with Custom Object ParentId is ID of Custom Object .

Error given is
Document: You cannot create a link for a document in a private library.

EXCEPTION_THROWN [356]|System.DmlException: Insert failed. First exception on row 0; first error: FIELD_INTEGRITY_EXCEPTION, You cannot create a link for a document in a private library: [ContentDocumentId]

Following is my Code ,

        public ID createFileFromUploadedFile(Id parentId) {
        ID docID = null;
        ContentVersion cv = new ContentVersion();
        cv.versionData =  file.Body;
        cv.title = file.FileName;
        cv.pathOnClient = file.FileName;
    insert cv;

    docID = cv.id;
        ContentVersion currentDoc = [SELECT ContentDocumentId from 
                                     ContentVersion  where id =:docID];
        docID = currentDoc.ContentDocumentId;
        ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = currentDoc.ContentDocumentId;
        cdl.LinkedEntityId = parentId;
        cdl.ShareType = 'S';
        insert cdl;

    return docID;

how to translate custom pick list value from custom object?

I created a Custom Object (Payment terms mapping) which have 2 fields, term_code & term_value. I imported a list of code & value into this table.

then I have a custom picklist field in my Opportunity (Term of payment) which have only 1 value (-None-). The reason is because I want to load the list of records from ‘Payment terms mapping’ object as value list into this picklist.

this custom picklist is displayed in my VFP and this is how I do it

Apex controller

 public List getPaymentList(){
 List paymentList = [Select code, value from Payment_Term_Mapping__c];
 for(Integer k=0; k< paymentList.size(); k++){
        options.add(new SelectOption(paymentList[k].code, paymentList[k].value));

my VFP


I translated all the value in Payment terms mapping but when I display the custom picklist(Term of payment) in my VFP it still show English version. How can I also display the translated value in my VFP?