pre_get_posts redirecting

you can allow only registered user to see your content by 1.this solution for post show only to login user class RavsPublic { function __construct() { add_action(‘pre_get_posts’, array($this, ‘try_redirect’)); } function try_redirect( $query ) { // not on home page and not login if( !is_home() && !is_user_logged_in() ){ // send them to home page wp_redirect( … Read more

Posts2Posts, wp_query and orderby issue

I don’t have any experience with posts2posts, but to see the query that wp_query runs on your database, before your if statement, put echo $new_connected->request. Helped me a lot to debug wp_query when I couldn’t find out which parameters weren’t working. The output is the SQL query that will be performed on the DB. Therefor … Read more

What query to append the 10 next posts?

You need the $paged param and pass it with the ajax call. $queryLoadPosts = new WP_Query(array( ‘post_type’ => ‘track’, ‘posts_per_page’ => 4, ‘paged’ => (isset($_REQUEST[‘paged’]) && intval($_REQUEST[‘paged’])) ? $_REQUEST[‘paged’] : 1 )); First time you click the button the paged param must be 2, second time 3, and so on… so you need to store … Read more

confirm my booking with phone number

I understand your problem but in your question your going from submission of a form to querying data you expect in the database then displaying it. That covers a lot of steps. My first question is have you confirmed that your submitted form values are being stored as you expect? We need to rule out … Read more

get contents and permalink from a specified page

To display content and permalink of About Us page you should use get_permalink() function by passing page id to it and instead of the_content_rss() function, you should directly echo $page->post_content by trimming content using wp_trim_words() function. The changed code is as following. <?php $page = get_page_by_title( ‘About Us’ ); $content = apply_filters(‘the_content’, $page->post_content); echo wp_trim_words( … Read more

custom query to get posts

Clarification of your question: You want to show Posts of a certain category named “ABC” AND also you want to filter the posts with the tag named “XYZ”. Answer: If this is the scenario, have you tried: WP_Query()? <?php // The Query $args = array(‘post_type’ => ‘post’, ‘category_name’ => ‘ABC’, ‘tag’ => ‘XYZ’, ‘meta_key’ => … Read more

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