WPBakery Post Grid Custom Query - wordpress

I am using WPBakery and I would like to use the Post Grid to display the child pages of the current page. I understand that I can use a custom query within WPBakery, however, I am struggling with fetching the current post ID which is accepted by WPB.
I have a custom post type called 'partners' and some have child pages which I would like to bring through using the grid.
I'm looking to turn this into a custom query which is accepted by WPBakery.
$args = array(
'post_parent' => $post->ID,
'posts_per_page' => -1,
'post_type' => 'partners',
);

When use the Post Grid to display the child pages of the current page.
I use string:post_parent="parent page ID"&posts_per_page=-1&post_type=page

Related

Code star framework add metabox to a specific page

I am using the code star framework full version. I have integrated the framework with the theme. How can I show the meta box option only for some specific pages ( like home page and about page )? Currently, the meta box options are showing all pages.
While creating metabox, you should pass "page_templates" value in array. For example, if you want to show metabox on homepage you should do:
$homePage = 'home-page';
CSF::createMetabox($homePage, array(
'title' => 'Homepage',
'post_type' => 'page',
'page_templates' => 'index.php', //filename goes here
'data_type' => 'serialize',
));
For more info: http://codestarframework.com/documentation/#/configurations?id=metabox-option-framework

Show Child post of Specific Parent on any page in Wordpress

I want to be able to use a shortcode to list a child post for a specfic parent on any page (custom post types mainly).
I found this: Show Child-pages of Specific Parent on any page in Wordpress
and it's perfect, but only for "pages" I think, it is not working for me with Custom Post Types.
Guillem,
You can keep use the code from this link.
Just add your custom post types in wp_list_pages function.
So, you will have:
$childpages = wp_list_pages( array(
'child_of' => $post->ID,
'title_li' => '',
'post_type' => 'YOUR_CPT_SLUG',
'echo' => 0,
) );

hide page wordpress except if you have direct link(how to hide it from indexing, etc)

I have a part of site(one page) that I want to hide and you can access it only if you have a direct link(you don't need to be registered user(public)). So what I need to do to hide it from indexing and stuff like that(I know that is the only way to protect it if page has status public.
Considering you are using loops everywhere for showing posts.
Add 'post__not_in' => array($post_ID) wherever you are using the loop in the query.
$my_query = new WP_Query(
array(
......,
......,
'post__not_in' => array($post_ID)
));
This would remove that post from the loop,hence will not show it.

Is it possible to create wordpress category pages like home pages? (designed)

I see in most WP templates that the homepage is very beautiful, designed with banners etc. Is it possible to do the same for each category page (after all these pages are landing pages)?
I want it to show both promotional stuff on top (banners etc.) and latest category posts on bottom. The default is only latest posts.
Thanks
Firstly your question is not clear and you just asked a general question for that answer is Yes absolutely Possible. Without any specific information of theme or error, we cant help you.
Here is some thought:
You can easily customize wordpress theme category page category.php or even if you want a different category template for only one category, you can do that. To do that, create category-[slug].php or category-[id].php file in your theme files - replace slug or id whatever you use with that of category you want a different tempelate.
Once you edit template for category page, you can add all options yourself - Good option is to display a Slider of category page and query posts for that category only to show on that slider or show promotional stuff on top from that category in slider or show banners whatever you want.
For example, you can alter your query to display latest posts from that category only to show in slider etc like using following query:
$current_category = single_cat_title("", false);
$args = array(
'numberposts' => 5,
'offset' => 0,
'category_name' => $current_category,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish' );
$recent_posts = get_posts( $args );
If it's using WP_Query, your query should look something like this:
$current_category = single_cat_title("", false);
$cat_posts = new WP_Query('showposts=5&category_name='.$current_category);
while ($cat_posts->have_posts())
...
And of course you can put a flag for promoted offer posts in your database as well and then add parameter of 'promoted' => 'true' in above example queries to show only promoted posts in that slider etc.
p.s I just gave general thought - you need some knowledge of php, wordpress API for this and this is easily possible.
Vote up for me and accept the answer if i helped you.
There are many themes available in market with such options as well that you can use.

Wordpress query from Magento/WHMCS return wrong result

I am trying to display posts from a specific cateogry in WordPress in a footer column on a site. It works fine unless the footer is displaying on a page that is integrated in either WHMCS or Magento. For some reason, on those pages within those apps, it still displays the blog post column, but instead of returning the last X # of posts in the specified category, it seems to return the last post X # of times.
For example, here is the stand alone Wordpress blog column pulling from a specific category:
http://www.thinkshovels.com/includes/latest_work.php
This is exactly what we want shown throughout the site, however if you visit http://www.thinkshovels.com/service/ you can see that the middle column is not displaying that info.
Here is the code querying wordpress:
define('WP_USE_THEMES', false);
require('/home/shovels/public_html/blog/wp-load.php');
$qarray = array('cat' => '5', 'posts_per_page' => 4);
query_posts($qarray);
while (have_posts()): the_post();
$args = array( 'post_type' => 'attachment', 'numberposts' => -1,
'post_status' => null, 'post_parent' => $post->ID );
I'm not sure if I have done something wrong here, or if there is a better way to approach this, but it seems that WHMCS and Magento break something with these queries.
Any tips/advice appreciated! Thanks.
Instead of query_posts try to use get_posts instead.
According to the article from Developer.WordPress.com you should avoid using query_posts.

Resources