Function in array as arguments for WP_Query

I suspect the problem is coming from $MyCustomField which you enter as such in: ‘terms’ => array( $MyCustomField ), The query consider it as only one value: ‘64,72’, a string. So try: $MyCustomFieldValues = array_map( ‘intval’, explode( ‘,’, $MyCustomField ) ); This will also ensure your values are integers. Then: ‘terms’ => $MyCustomFieldValues,

Make loop display posts by alphabetical order

To display posts in descending alphabetical order add this to your args array (taken from the wp codex) ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, To display posts in ascending alphabetical order just switch DESC to ASC. So the whole thing would look like: $args = array( ‘orderby’ => ‘title’, ‘order’ => ‘DESC’, ); $query = … Read more

Search custom taxonomy term by name

// We get a list taxonomies on the search box function get_tax_by_search($search_text){ $args = array( ‘taxonomy’ => array( ‘my_tax’ ), // taxonomy name ‘orderby’ => ‘id’, ‘order’ => ‘ASC’, ‘hide_empty’ => true, ‘fields’ => ‘all’, ‘name__like’ => $search_text ); $terms = get_terms( $args ); $count = count($terms); if($count > 0){ echo “<ul>”; foreach ($terms as … Read more

paginate_links() adds empty href to first page and previous link

Have you tried specifying the base and format arguments for paginate_links()? It assumes the default values of: ‘base’ => ‘%_%’, ‘format’ => ‘?page=%#%’, Your base should be something like /parent-page/child-page/%_%; then the first page link will be to /parent-page/child-page/, and subsequent links will follow the format /parent-page/child-page/?page=3 (example for page 3). In the base, the … Read more

Pagination returns 404 after page 20

What you are experiencing is quite normal and expected. This is one of the big reasons I always hammer on this point, never use custom queries to replace the main query on the home page or any type of archive page. They solve one issue but creates plenty other new ones Lets look at what … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)