Articles of single

What is wrong with my WP_Query Arguments?

In my single.php file I am using a nested WP_Query to show more posts, at the bottom of the page. My code for the query and nested loop are as follows: <?php $ep_args = array( ‘post_type’ => ‘post’, ‘category_not_in’ => 93, ‘orderby’ => ‘rand’, ‘posts_per_page’ => 4, ‘offset’ => 1, ); $ep_query = new WP_Query( […]

How to use apply_filters?

So I am using a plugin which loads next posts as the user scrolls down in the single.php file. Inside the main php file of the plugin, there is something along the lines of // By default, don’t query for a specific page of a paged post object. // This argument can come from merging […]

Single.php the_excerpt loads same as the_content not loading read more line

Currently I’m using the the_excerpt on my frontpage which works perfectly. When the visiter goes to the post it first needs to read the first part of the story, see a featured image and then load the rest of the content. Currently I have this: <?php the_excerpt(); ?> <?php the_post_thumbnail( ‘blog-full’, array( ‘class’ => ‘img-responsive […]

adding custom post type “name” to single template

i created a custom post type called 30 day boot camp using this code: add_action( ‘init’, ‘rt_custom_post’ ); function rt_custom_post() { register_post_type( ’30-day-boot-camp’, array( ‘labels’ => array( ‘name’ => __( ‘Boot Camps’ ), ‘singular_name’ => __( ‘Boot Camp’ ), ‘add_new’ => _x(‘Add New’, ‘Boot Camp’), ‘add_new_item’ => __(“Add New Boot Camp”), ‘edit_item’ => __(“Edit Boot […]

how to make an array of post id's in is_single

For example, the code below only shows the page challenge for post id 2578. However i got 8 other posts that should have the same layout. All others should have the layout from challenge-2 etc. I was hoping i could do that by just adding commas between the ID’s. like 2578, 2579, 2580 but that […]

Add_action to wp_head via functions.php

I installed the Twenty Seventeen theme and a child theme. Now I want to add the following code to functions.php to add meta data to the <head> tag using the wp_head action: if ( is_single() ) echo get_post_meta($post->ID, “meta-head”, true); ?> I tried this, but it did not work: add_action (‘wp_head’,’hook_inHeader’); function hook_inHeader() { if […]

single.php with different look by category

I’m trying to find a way to get my posts with different look depending on their category. I have first tried to do it using the template hierarchy but it seems there is no pattern for the category posts. (ie single-cat-mycategory.php) So then within single.php I tried the conditional tagging using is_category() but my understanding […]

Get next post in same category not working WP 4.7.4

I have posts which assigned 1 of 2 different categories. On the single post view i want to show a next and previous link of posts with the SAME category. This should be straightforward, i’ve tried using get_previous_post etc but i cannot exclude posts assigned to the other category. I’ve tried $prevPost = get_adjacent_post(TRUE,’129′,TRUE); where […]

Creating php pages in wordpress and assigning them to wordpress pages

/I have few pages in my wordpress site which should contain some php code. For example news page. In my front-page.php I have a while which loops trough all posts and prints few news. In my news site I want to do the same. I have already tried using <?php /* Template Name: news */ […]

Simple way to style posts of a single category differently in the loop and in single

I have a certain category of posts (let’s say the category is punk-rockers) that I would like to: be styled differently from other posts in my main loop (index.php) and have single posts (single.php) which are styled differently from my other posts. So, there will be four different styles, in total: default loop special-category loop […]