Display post of specific category on page

There’s nothing in your code that outputs anything for each post. That’s not what $arr_posts->the_post(); does. You need to use template tags like the_title() and the_content() to output those fields: while ($arr_posts->have_posts()) { $arr_posts->the_post(); the_title( ‘<h2>’, ‘</h2>’ ); the_content(); }

Pagination in category.php not functioning

if your aim is to restrict the category archive to your post_type ‘video’ and to 6 posts per page, do not edit category.php, rather use ‘pre_get_posts’ https://developer.wordpress.org/reference/hooks/pre_get_posts/ example code for your case: add_action( ‘pre_get_posts’, ‘category_post_type_video_custom’ ); function category_post_type_video_custom( $query ) { if ( ! is_admin() && $query->is_main_query() ) { // Not a query for an … Read more

Adding php within a return statement [closed]

You can just call PHP functions directly. In this case however we possibly don’t want to call the_permalink() since it echoes out the link: function the_permalink( $post = 0 ) { /* … */ echo esc_url( apply_filters( ‘the_permalink’, get_permalink( $post ), $post ) ); } whereas we want to return the link in a string. … Read more

Parse error: syntax error, unexpected ‘}’ in C:\wamp64\www\Proiect\aplicatie\user_check.php on line 18 [closed]

The semi-colons need to go inside the curly braces, to mark the ends of the array_push() statements: if(empty($username)) { array_push($errors, “Username is required”); } if(empty($email)) { array_push($errors, “Email is required”); } if(empty($password)) { array_push($errors, “Password is required”); } You don’t need semi-colons after the close braces.

Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in C:\xampp\htdocs\AttendanceSystem\resources\php\method.php on line 250 [closed]

You don’t need to echo it. You can just add it to the string since we’re in PHP at that point: ‘<span style=”font-size: 16px;”>’ . esc_html( $student_name ) . ‘</span></span></p>’ You should also escape any variables you’re adding to HTML strings using esc_html() in case the strings contain HTML tags not just plain text.

How can I execute $string = if();? [closed]

You have a few options to assign that value into $string but ill show two First using regular if $string = ”; if (!empty($_GET[‘category’]) { $string = $_GET[‘category’]; } Second using ternary operator $string = !empty($_GET[‘category’]) ? $_GET[‘category’] : ”; When working with data that you receive from outer sources, for example, inputs, url etc… … Read more

why my “recepie” category is not taken into account in my request

This explicit code is missing from your example and you should verify that you have at least these statements (plus any additional post tag functions, or analogous calls to “the_content()”) included exactly as this in your original code: while ( $the_query->have_posts() ) : $the_query->the_post(); the_content(); endwhile; This should roughly be at the location noted by … Read more

Alternative loop syntax error [closed]

Because you’re using semicolons when you should be using colons after the if and the while 🙂 query_posts( ‘year=2011’ ); if ( have_posts() ): while ( have_posts() ): the_post(); the_title(); endwhile; wp_reset_query(); endif; That works just fine.