Tag Info

Hot answers tagged

3

You can approach this by first using a database query to count the number of pages that are already using the template: $query = "SELECT COUNT(*) as total FROM prefix_posts as p JOIN prefix_postmeta as m ON p.ID = m.post_id WHERE p.'post_type' = 'page' AND p.'post_status' = 'publish' AND m.'meta_key' = '_wp_page_template' AND ...


3

get_the_content( $more_link_text, $stripteaser ) get_the_content does not take a post ID as a parameter, it always refers to the current post. Also, don't use magic numbers or hardcode post IDs into your theme, it will break after an import/export or migration. Instead use get_page_by_title, which is not as bad: // get the post $post = ...


1

I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you while() statement you have the_post(). This doesn't work in secondary queries, it should look like: <?php if( $subpages->have_posts() ) : ?> <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?> ...


1

There is nothing build-in to create the drop-down for you, so you have to do it yourself. To get the needed information you can use get_post_types() to get the post types you want, set the $args parameter accordingly. Additionally make sure to set the $ouput parameter to objects, because you need the data provided - it defaults to names and then you will ...


1

You get that error, because the $_GET and $_POST are not filled on every admin page with that data. Also, your code should never rely on globals, they can be changed by any other code, so they are not reliable. So don't use global $post;, $_POST or $_GET when you can get the information from better sources like here. Use the action add_meta_boxes to … well ...


1

You will create a page template whose file name is custompage-template.php here I suppose put in in your plugin dir/views/ folder. Whenever the page whose title is Your Page Name is visited, the site will render your custom template add_filter( 'page_template', 'fw_reserve_page_template' ); function fw_reserve_page_template( $page_template ) { if ( ...


1

When adding an external link you need to include HTTP:// or HTTPS:// at the start of the URL to link to an external domain. Otherwise the link will be added onto the current domain.


1

Why do you need to manually enter it? The ::before and ::after are there even without declaration. li::before { some rules... } li::after { some rules... } Here is an article that describes it.


1

You can't write this syntax directly to plain HTML code. ::berfore element is added to HTML tag only when it is defined in CSS stylesheet (like denis.stoyanov wrote).


1

The template for the page is called page.php and should be in the same theme folder as index.php (alternatively you can use the is_page() function to do a template inside index.php but it's more difficult and there's little point to that). Best way forward is to study an existing theme and figure how things work. A look at the template hierarchy should help ...



Only top voted, non community-wiki answers of a minimum length are eligible