All Questions
158
questions
0
votes
0
answers
36
views
get last part of page url and add it as cat in wp_query
I have a page URL : https://mwallpaper.ir/mobile-wallpapers/birds
and I grabbed last part of URL with this filter :
add_filter( 'example_filter', 'catslug_callback' );
function catslug_callback( $...
0
votes
1
answer
41
views
wp_logout action hook is not firing
Why the user meta value is not being changed after logout using the following code:
function update_login_status_on_logout() {
$user_id = get_current_user_id();
if ($user_id) {
...
0
votes
1
answer
41
views
Excluding a category from frontpage but not from WP_Query
I am successfully using this functions.php snippet to exclude category 3 from the WordPress homepage:
function exclude_category_home( $query ) {
if ( $query->is_front_page ) {
$query->set( 'cat',...
1
vote
1
answer
61
views
Filters do not work when there are multiple (one works)
I have this functions code:
function my_query($query)
{
if (is_post_type_archive('mycustomposttype')) {
$orderby = sanitize_text_field(get_query_var('orderby'));
$orderby2 = ...
0
votes
0
answers
2k
views
a problem in class in class-wp-hook.php
I get the problem this morning
Warning: call_user_func_array() expects parameter 1 to be a valid
callback, function 'wp_ob_end_flush_all' not found or invalid function
name in /home/legotechnic/...
-1
votes
1
answer
22
views
Insert image between X number of posts but on specific paginated pages?
I'm inserting an image in-between every 5th post using the code below but obviously it shows up on every paginated page. Is there a "pagination" function available to show the image every ...
0
votes
1
answer
24
views
change the default order of posts only for specific categories
I want to change the default ordering for posts, to last modified date, but only for certain categories pages (when visiting certain category pages)
I have this function code, which is working, but I ...
0
votes
1
answer
322
views
Reset postdata not working on WP_Query in functions.php
I'm running a WP_Query in my functions.php, so I can easily access some ACF-fields in my code without having to run that query on every page.
However, the loop changes the post ID to the CPT I'm ...
0
votes
1
answer
41
views
Let current user know pending posts counts using wp_query
I'm working on a query to let a logged-in user know if the user has more than 5 pending posts. Here's what I ended up with:
// Start the query
$query = new WP_Query( array(
'post_type' => '...
0
votes
1
answer
107
views
Isn't Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
I'm trying to count rows in sql table using SELECT COUNT(*) for the post view count. My code is
function get_post_views($offset=0, $post_id){
global $wpdb;
$get_visit_query = "...
0
votes
1
answer
62
views
set object terms after some some time of published post - functions.php
I have to change the published post in one category to another category after some days. I have created the below code for the function, which I have added in the functions.php file in child-theme. ...
0
votes
1
answer
40
views
Wp-query Order By problem
I'm trying to sort a query according to the order they write it in but it takes an order by ID.
The variable $idpaginas prints: 20659,20626,20585,20616,18464,19748,19991,18520,20588,21268,18753,20556,...
1
vote
1
answer
424
views
Wp_query function to search from product_title 'OR' product tags name
I am looking to show search results from either product title or product tag name. I have implemented the product title search through the below code, but I need to add tag name search also into it. ...
0
votes
2
answers
387
views
How to check in functions.php if there is data in a WP_Query?
I have 2 different WP Query on the home page.
I need to check $home_query condition in functions.php then I want to do something if $home_query returns null.
I tried with pre_get_posts action I couldn'...
0
votes
1
answer
164
views
How is $current_page passed in woocommerce_account_orders function?
The woocommerce function woocommerce_account_orders($current_page) has 1 parameter called $current_page. The function is called via woocommerce_account_orders_endpoint via the following hook - ...